Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Rapid Prototyping Lab
Python Modules
BMJV
Commits
35736aaf
Commit
35736aaf
authored
Oct 23, 2019
by
Christian Lölkes
Browse files
Version 1.2.0
parent
e1708b79
Changes
4
Hide whitespace changes
Inline
Side-by-side
BMJV/__init__.py
View file @
35736aaf
...
...
@@ -26,23 +26,6 @@ import logging, time
logger
=
logging
.
getLogger
(
__name__
)
URLS
=
{
# Rechtssprechung des Bundesverfassungsgerichts
'bverfg'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bverfg.xml'
,
# Rechtsprechung des Bundesgerichtshofs
'bgh'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bgh.xml'
,
# Rechtsprechung des Bundesverwaltungsgerichts
'bverwg'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bverwg.xml'
,
# Rechtsprechung des Bundesfinanzhofs
'bfh'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bfh.xml'
,
# Rechtssprechung des Bundesarbeitsgerichts
'bag'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bag.xml'
,
# Rechtssprechung des Bundessoszialgerichts
'bsg'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bsg.xml'
,
# Rechtssprechung des Bundespatengerichts
'bpatg'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bpatg.xml'
}
class
Law
(
object
):
def
__init__
(
self
,
data
):
self
.
dateString
=
'%a, %d %b %Y %H:%M:%S GMT'
...
...
@@ -118,7 +101,26 @@ class BGBl(object):
def
formatted
(
self
):
return
u
'{} - {} - {}'
.
format
(
self
.
pubDate
,
self
.
title
,
self
.
description
)
class
RechtsprechungImInternet
(
object
):
URLS
=
{
# Rechtssprechung des Bundesverfassungsgerichts
'bverfg'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bverfg.xml'
,
# Rechtsprechung des Bundesgerichtshofs
'bgh'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bgh.xml'
,
# Rechtsprechung des Bundesverwaltungsgerichts
'bverwg'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bverwg.xml'
,
# Rechtsprechung des Bundesfinanzhofs
'bfh'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bfh.xml'
,
# Rechtssprechung des Bundesarbeitsgerichts
'bag'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bag.xml'
,
# Rechtssprechung des Bundessoszialgerichts
'bsg'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bsg.xml'
,
# Rechtssprechung des Bundespatengerichts
'bpatg'
:
'https://www.rechtsprechung-im-internet.de/jportal/docs/feed/bsjrs-bpatg.xml'
}
def
__init__
(
self
,
id
):
self
.
id
=
id
self
.
feed
=
self
.
selectCourt
()
...
...
@@ -135,8 +137,8 @@ class RechtsprechungImInternet(object):
self
.
__id
=
value
if
value
else
'bverfg'
def
selectCourt
(
self
):
if
self
.
id
in
URLS
:
return
API
(
url
=
URLS
[
self
.
id
],
format
=
'xml'
)
if
self
.
id
in
self
.
URLS
:
return
API
(
url
=
self
.
URLS
[
self
.
id
],
format
=
'xml'
)
else
:
return
False
...
...
BMJV/__main__.py
View file @
35736aaf
...
...
@@ -20,30 +20,58 @@
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
"""Retrieve Data from the BMJV
Usage:
BMJV [options]
BMJV [--mode <mode>] [--court <court>] [--loglevel LEVEL] [--limit <limit>]
BMJV (-h | --help | -v | --version)
Options:
-h --help Show this screen
-v --version Show version
--loglevel LEVEL Set a specific log level [default: INFO]
Data options:
--court <court> Select a specific court [default: bverfg]
--mode <mode> Select a data source [default: rim]
--limit <limit> Limit the amount fo results to diplay [default: 0]
--list-courts Show all available courts
"""
VERSION
=
'1.2.0'
### docopt ###
from
docopt
import
docopt
arguments
=
docopt
(
__doc__
,
version
=
VERSION
)
### Logging ###
import
logging
logging
.
basicConfig
(
format
=
'%(asctime)s - %(name)s - %(levelname)s: %(message)s'
,
datefmt
=
'%d-%b-%y %H:%M:%S'
,
level
=
getattr
(
logging
,
arguments
[
'--loglevel'
])
)
from
datetime
import
datetime
from
obelixtools
import
API
import
logging
,
time
import
argparse
import
time
from
BMJV
import
*
if
__name__
==
'__main__'
:
logger
=
logging
.
getLogger
(
__name__
)
parser
=
argparse
.
ArgumentParser
()
parser
.
add_argument
(
'--mode'
,
choices
=
[
'bgbl'
,
'rim'
],
help
=
'Seth mode.'
)
parser
.
add_argument
(
'--court'
,
type
=
str
,
default
=
'bverfg'
,
help
=
'Select a court. Only relevant if in rim mode.'
)
parser
.
add_argument
(
'--limit'
,
type
=
int
,
default
=
0
,
help
=
'Limit the number of results.'
)
args
=
parser
.
parse_args
()
logging
.
basicConfig
(
level
=
logging
.
INFO
)
if
args
.
mode
==
'rim'
:
rim
=
RechtsprechungImInternet
(
args
.
court
)
rim
.
fetch
(
args
.
limit
)
if
arguments
[
'--list-courts'
]:
logger
.
info
(
'The follwing IDs are available for --court'
)
for
id
,
link
in
RechtsprechungImInternet
.
URLS
.
items
():
logger
.
info
(
'{} - {}'
.
format
(
id
,
link
))
elif
arguments
[
'--mode'
]
==
'rim'
:
rim
=
RechtsprechungImInternet
(
arguments
[
'--court'
])
rim
.
fetch
(
int
(
arguments
[
'--limit'
]))
for
item
in
rim
.
items
:
logger
.
info
(
item
.
formatted
)
elif
args
.
mode
==
'bgbl'
:
elif
arguments
[
'--mode'
]
==
'bgbl'
:
gim
=
BGBl
()
gim
.
fetch
(
args
.
limit
)
gim
.
fetch
(
int
(
arguments
[
'--
limit
'
])
)
for
item
in
gim
.
items
:
logger
.
info
(
item
.
formatted
)
CHANGELOG
View file @
35736aaf
...
...
@@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
## [1.2.0] 2019-10-23
### Added
- List all available courts with ```python -m BMJV --list-courts```
### Changed
- Dictionary URLS is now in the ```RechtsprechungImInternet``` class.
### Changed
- CLI Arguments are now parsed with docopt
- Log messages include name of the file for each message.
## [1.1.0] 2019-10-20
### Added
- __main__.py so the module can be used as standalone script.
...
...
@@ -16,8 +26,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Law.parse()
- Judicature.parse()
### Changed
## [1.0.0] 2019-10-19
- Initial release
setup.py
View file @
35736aaf
...
...
@@ -27,7 +27,7 @@ with open('README.md', 'r') as fh:
setuptools
.
setup
(
name
=
'BMJV'
,
version
=
'1.
1
'
,
version
=
'1.
2.0
'
,
author
=
'Christian Lölkes'
,
author_email
=
'christian.loelkes@gmail.com'
,
description
=
'Data from the Federal Ministry of Justice and Consumer Protection'
,
...
...
@@ -39,9 +39,13 @@ setuptools.setup(
'Programming Language :: Python :: 3'
,
'License :: OSI Approved :: MIT License'
,
'Operating System :: OS Independent'
,
'Intended Audience :: Legal Industry'
,
'Intended Audience :: Education'
,
'Natural Language :: German'
],
python_requires
=
'>=3.6'
,
install_requires
=
[
'obelixtools'
'obelixtools'
,
'docopt'
],
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment