Welcome to personroles’s documentation!

Overview

deployment:https://img.shields.io/pypi/v/personroles https://img.shields.io/pypi/pyversions/personroles.svg https://img.shields.io/pypi/implementation/personroles.svg
test/coverage:https://app.codacy.com/project/badge/Grade/5a29d30f3ec7470cb17085a29a4c6a8f https://codecov.io/gh/0LL13/person/branch/master/graph/badge.svg https://api.codeclimate.com/v1/badges/714a256d1edf47898a22/maintainability https://coveralls.io/repos/github/0LL13/person/badge.svg?branch=master https://scrutinizer-ci.com/g/0LL13/person/badges/quality-score.png?s=0242cf58f51463f90ec17ee3d1708c07beaddd6624a07e9d228a2e337aa56388
build status:https://travis-ci.org/0LL13/person.svg?branch=master Updates https://img.shields.io/github/issues-pr/0LL13/person https://img.shields.io/badge/security-bandit-yellow.svg
docs:https://readthedocs.org/projects/personroles/badge/?version=latest https://img.shields.io/github/license/0LL13/person

A set of dataclasses concerning roles (academic, politician, …) of persons and their particulars

Features

Currently names of this structure are supported:

Names:                       first_name middle_name_1 middle_name_2 last_name/s
Names with academic title:   academic_title/s first_name ... last_name/s
Names with peer title:       peer_title/s first_name ... last_name/s
Names with peer preposition: first_name ... peer_preposition last_name/s
Names with all titles:       academic/peer_title first_name ... peer_preposition last_name/s

These roles have been sketched:

Academic - academic_title
Person - gender, born, age, deceased
Noble - peer_title, peer_preposition
Politician - minister, offices, party, parties
MoP - legislature, state, electoral_ward, ward_no, voter_count, parl_pres, parl_vicePres

Usage

from personroles import person

tom = person.Academic("Thomas H.", "Smith", academic_title="MBA")
print(tom)

Academic:
academic_title=MBA
first_name=Thomas
last_name=Smith
middle_name_1=H.
from personroles import mop_role

bob = mop_role.MoP("14", "NRW", "SPD", "Bob R.", "Smith", academic_title="Dr.", electoral_ward="Köln I")
print(bob)

MoP:
academic_title=Dr.
electoral_ward=Köln I
first_name=Bob
gender=male
last_name=Smith
legislature=14
membership={'14'}
middle_name_1=R.
parties=[Party(party_name='SPD', party_entry='unknown', party_exit='unknown')]
party_name=SPD
state=NRW
voter_count=121721
ward_no=13

Credits

This package was started with Cookiecutter and the audreyr/cookiecutter-pypackage project template. Also the project setup by Martin Heinz was very helpful. I felt the changes were necessary to keep the files containing the roles small.

Installation

pip install personroles

or

pipenv install personroles

Contribute

Please fork first and use for your own ends.
This package is structured like this:
personroles
├── mop_role.py
├── person.py
├── politician_role.py
├── your-contribution_role.py
├── resources
│   ├── constants.py
│   └── helpers.py
└── tests
    ├── test_mop.py
    ├── test_person.py
    ├── test_politician.py
    └── test_your-contribution.py

Because of its modular structure, all you need to do is add another role as “your-contribution_role.py”, and another test as “test_your-contribution.py”. Use current *_role modules as blueprint and delete if not needed.

Support

Fork and improve.

Planned

Fork and repeat with different roles.

Warranty

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

License

MIT License

Copyright (c) 2020 Oliver Stapel

Installation

Stable release

To install person, run this command in your terminal:

$ pip install personroles

or

$ pipenv install personroles

This is the preferred method to install person, as it will always install the most recent stable release.

If you don’t have pip installed, this Python installation guide can guide you through the process.

From sources

The sources for personroles can be downloaded from the Github repo.

You can either clone the public repository:

$ git clone git://github.com/0LL13/person

Or download the tarball:

$ curl -OJL https://github.com/0LL13/person/tarball/master

Once you have a copy of the source, you can install it with:

$ python setup.py install

Usage

Using person in a project:

from personroles import person

Using Name:

name = person.Name("Hans Hermann", "Bayer")
print(name)

Name:
first_name=Hans
last_name=Bayer
middle_name_1=Hermann

Using Noble:

noble = person.Noble("Dagmara", "Bodelschwingh", peer_title="Gräfin von")
print(noble)

Noble:
first_name=Dagmara
last_name=Bodelschwingh
peer_preposition=von
peer_title=Gräfin

Using Academic:

academic = person.Academic("Horst Heiner", "Wiekeiner",
                           academic_title="Dr.")
print(academic)

Academic:
academic_title=Dr.
first_name=Horst
last_name=Wiekeiner
middle_name_1=Heiner

Using Person:

person_1 = person.Person("Sven", "Rübennase", academic_title="MBA", born="1990")
print(person_1)

Person:
academic_title=MBA
age=30
born=1990
first_name=Sven
gender=male
last_name=Rübennase

Using Politician:

from personroles import politician_role

politician = politician_role.Politician("SPD", "Bärbel", "Gutherz", academic_title="Dr.",
                               date_of_birth="1980")
print(politician)

Politician:
academic_title=Dr.
age=40
born=1980
first_name=Bärbel
gender=female
last_name=Gutherz
parties=[Party(party_name='SPD', party_entry='unknown', party_exit='unknown')]
party_name=SPD

politician.add_Party("GRÜNE", party_entry="2017")

print(politician)

Politician:
...
parties=[Party(party_name='SPD', party_entry='unknown', party_exit='unknown'),
         Party('GRÜNE', party_entry='2017', party_exit='unknown')]
party_name='GRÜNE'

Using MoP:

from personroles import mop_role

mop = mop_role.MoP("14", "Grüne", "Tom", "Schwadronius", peer_title="Junker von",
                 born="1950")
print(mop)

MoP:
age=70
born=1950
first_name=Tom
gender=male
last_name=Schwadronius
legislature=14
membership={14}
parties=[Party(party_name='Grüne', party_entry='unknown', party_exit='unknown')]
party=Grüne
peer_preposition=von
peer_title=Junker

mop.add_Party("Grüne")
mop.change_ward("Düsseldorf II")
print(mop)

MoP:
age=70
born=1950
electoral_ward=Düsseldorf II
first_name=Tom
gender=male
last_name=Schwadronius
legislature=14
membership={14}
parties=[Party(party_name='SPD', party_entry='unknown', party_exit='unknown'),
         Party('GRÜNE', party_entry='unknown', party_exit='unknown')]
party_name=Grüne
peer_preposition=von
peer_title=Junker
voter_count=99022
ward_no=41

personroles

personroles package

Subpackages

personroles.resources package
Submodules
personroles.resources.constants module

Collection of constants like GERMAN_PARTIES, PEERTITLES, …

personroles.resources.helpers module

Helper functions: exceptions, print style, Party, …

class personroles.resources.helpers.AttrDisplay[source]

Bases: object

Mark Lutz, Programming Python Provides an inheritable display overload method that shows instances with their class names and a name=value pair for each attribute stored on the instance itself (but not attrs inherited from its classes). Can be mixed into any class, and will work on any instance.

gather_attrs() → list[source]

Check if attributes have content and add them to a list called attrs.

exception personroles.resources.helpers.NotGermanParty[source]

Bases: Exception

Only German parties, this will most likely not change.

exception personroles.resources.helpers.NotInRange[source]

Bases: Exception

For state NRW only terms 14 to currently term 17 are accepted.

class personroles.resources.helpers.Party(party_name: str, party_entry: str = 'unknown', party_exit: str = 'unknown')[source]

Bases: personroles.resources.helpers._Party_default, personroles.resources.helpers._Party_base, personroles.resources.helpers.AttrDisplay

Collect party name and entry/exit data.

class personroles.resources.helpers.Session(state: str, term: str, date: str, protocol_nr: str, page_from: str = 'unknown', page_to: str = 'unknown', expletive: str = 'unknown', kind: str = 'unknown', result: str = 'unknown', classification: str = 'unknown', tags: List[str] = <factory>, region: str = 'unknown', speakers: List[str] = <factory>)[source]

Bases: personroles.resources.helpers._Session_default, personroles.resources.helpers._Session_base, personroles.resources.helpers.AttrDisplay

A session’s details.

exception personroles.resources.helpers.TooManyFirstNames(message)[source]

Bases: Exception

Currently only one first name and two middle names are supported. Example: Tom H. Paul last_name

personroles.resources.mop_tinyDB module
Module contents

Some constants declarations, print styling, exceptions, and another container.

Module resources provides constants (like GERMAN_PARTIES, PEERTITLES, …) and helper functions like exceptions and data containers like Party that are needed for personroles.

Constants:
GERMAN_PARTIES PEERTITLES PEER_PREPOSITIONS
Helper functions:
exceptions:
NotInRange (legislature of state) NotGermanParty TooManyFirstNames (in Germany not more than three)
print style:
AttrDisplay
Party:
_Party_base:
party_name
_Party_default:
party_entry party_exit

planned: Speech:

_Speech_base:
speech_key
_Speech_default:
speech_content

Submodules

personroles.mop_role module

personroles.person module

personroles.politician_role module

Module contents

A set of dataclasses concerning roles of persons and their particulars.

Contributing

Contributions are welcome, and they are greatly appreciated! Every little bit helps, and credit will always be given.

You can contribute in many ways:

Types of Contributions

Report Bugs

Report bugs at https://github.com/0LL13/person/issues.

If you are reporting a bug, please include:

  • Your operating system name and version.
  • Any details about your local setup that might be helpful in troubleshooting.
  • Detailed steps to reproduce the bug.

Fix Bugs

Look through the GitHub issues for bugs. Anything tagged with “bug” and “help wanted” is open to whoever wants to implement it.

Implement Features

Look through the GitHub issues for features. Anything tagged with “enhancement” and “help wanted” is open to whoever wants to implement it.

Write Documentation

person could always use more documentation, whether as part of the official person docs, in docstrings, or even on the web in blog posts, articles, and such.

Submit Feedback

The best way to send feedback is to file an issue at https://github.com/0LL13/person/issues.

If you are proposing a feature:

  • Explain in detail how it would work.
  • Keep the scope as narrow as possible, to make it easier to implement.
  • Remember that this is a volunteer-driven project, and that contributions are welcome :)

Get Started!

Ready to contribute? Here’s how to set up person for local development.

  1. Fork the person repo on GitHub.

  2. Clone your fork locally:

    $ git clone git@github.com:your_name_here/person.git
    
  3. Install your local copy into a virtualenv. Assuming you have virtualenvwrapper installed, this is how you set up your fork for local development:

    $ mkvirtualenv person
    $ cd person/
    $ python setup.py develop
    
  4. Create a branch for local development:

    $ git checkout -b name-of-your-bugfix-or-feature
    

    Now you can make your changes locally.

  5. When you’re done making changes, check that your changes pass flake8 and the tests, including testing other Python versions with tox:

    $ flake8 person tests
    $ python setup.py test or pytest
    $ tox
    

    To get flake8 and tox, just pip install them into your virtualenv.

  6. Commit your changes and push your branch to GitHub:

    $ git add .
    $ git commit -m "Your detailed description of your changes."
    $ git push origin name-of-your-bugfix-or-feature
    
  7. Submit a pull request through the GitHub website.

Pull Request Guidelines

Before you submit a pull request, check that it meets these guidelines:

  1. The pull request should include tests.
  2. If the pull request adds functionality, the docs should be updated. Put your new functionality into a function with a docstring, and add the feature to the list in README.rst.
  3. The pull request should work for Python 3.5, 3.6, 3.7 and 3.8, and for PyPy. Check https://travis-ci.com/0LL13/person/pull_requests and make sure that the tests pass for all supported Python versions.

Tips

To run a subset of tests:

$ pytest tests.test_person

Deploying

A reminder for the maintainers on how to deploy. Make sure all your changes are committed (including an entry in HISTORY.rst). Then run:

$ bump2version patch # possible: major / minor / patch
$ git push
$ git push --tags

Travis will then deploy to PyPI if tests pass.

Credits

Development Lead

Contributors

None yet. Why not be the first?

History

0.1.0 (2020-08-20)

  • First release on PyPI.

0.1.7 (2020-09-27)

  • pip install works

Indices and tables