| ... | ... |
@@ -2,9 +2,101 @@ |
| 2 | 2 |
|
| 3 | 3 |
[Scrape][] [intranet.bygglogistik.se][]. |
| 4 | 4 |
|
| 5 |
+`bygglogistik-utils` is a [Python][] program that logs in to |
|
| 6 |
+[intranet.bygglogistik.se][] and reads and processes the data there. |
|
| 7 |
+ |
|
| 5 | 8 |
[`bygglogistik-utils`]: https://git.rcrnstn.net/rcrnstn/bygglogistik-utils |
| 6 | 9 |
[scrape]: https://en.wikipedia.org/wiki/Web_scraping |
| 7 | 10 |
[intranet.bygglogistik.se]: http://intranet.bygglogistik.se |
| 11 |
+[Python]: https://www.python.org |
|
| 12 |
+ |
|
| 13 |
+## Usage |
|
| 14 |
+ |
|
| 15 |
+`bygglogistik-utils --help`: |
|
| 16 |
+ |
|
| 17 |
+``` |
|
| 18 |
+bygglogistik-utils 1.0.0 |
|
| 19 |
+ |
|
| 20 |
+Scrape intranet.bygglogistik.se. |
|
| 21 |
+ |
|
| 22 |
+Usage: |
|
| 23 |
+ bygglogistik-utils pay [--tax=<tax>] |
|
| 24 |
+ bygglogistik-utils personnel |
|
| 25 |
+ bygglogistik-utils report [<date_from>] [<date_to>] [<region>] [<project>] |
|
| 26 |
+ bygglogistik-utils path |
|
| 27 |
+ bygglogistik-utils -h|--help |
|
| 28 |
+ bygglogistik-utils --version |
|
| 29 |
+ |
|
| 30 |
+Arguments: |
|
| 31 |
+ <date_from> |
|
| 32 |
+ The date (in a ISO 8601 format) from which to gather reports (inclusive). |
|
| 33 |
+ Defaults to yesterday. |
|
| 34 |
+ <date_to> |
|
| 35 |
+ The date (in a ISO 8601 format) to which to gather reports (inclusive). |
|
| 36 |
+ Defaults to <date_from>. |
|
| 37 |
+ <region> |
|
| 38 |
+ The region of the report. |
|
| 39 |
+ Defaults to the region of the logged in user. |
|
| 40 |
+ <project> |
|
| 41 |
+ The project of the report. |
|
| 42 |
+ Default to all projects. |
|
| 43 |
+ |
|
| 44 |
+Options: |
|
| 45 |
+ --tax=<tax> |
|
| 46 |
+ The tax rate, between 0.0 and 1.0. |
|
| 47 |
+ Defaults to 0.30. |
|
| 48 |
+``` |
|
| 49 |
+ |
|
| 50 |
+Data is stored in a path retrievable by running `bygglogistik-utils path`. This |
|
| 51 |
+path can be overridden with the [environment variable][] `BYGGLOGISTIK_PATH`. |
|
| 52 |
+ |
|
| 53 |
+Login uses the credentials in the file `$BYGGLOGISTIK_PATH/login` which should |
|
| 54 |
+be in [JSON][] format consisting of an object with the keys `email` and |
|
| 55 |
+`password`: |
|
| 56 |
+ |
|
| 57 |
+```json |
|
| 58 |
+{
|
|
| 59 |
+ "email": "name@example.com", |
|
| 60 |
+ "password": "mysupersecretpassword" |
|
| 61 |
+} |
|
| 62 |
+``` |
|
| 63 |
+ |
|
| 64 |
+Login credentials can be overridden by the [environment variable][]s |
|
| 65 |
+`BYGGLOGISTIK_EMAIL` and `BYGGLOGISTIK_PASSWORD`. |
|
| 66 |
+ |
|
| 67 |
+[environment variable]: https://en.wikipedia.org/wiki/Environment_variable |
|
| 68 |
+[JSON]: https://en.wikipedia.org/wiki/JSON |
|
| 69 |
+ |
|
| 70 |
+### `pay` command |
|
| 71 |
+ |
|
| 72 |
+Stores and summarizes personal payment data by parsing the table "Genomförda |
|
| 73 |
+intransporter" on the page "Mina sidor". |
|
| 74 |
+ |
|
| 75 |
+Since only the most recent data is shown in the table it then stores it locally |
|
| 76 |
+in `$BYGGLOGISTIK_PATH/pay` to enable accumulation over time (e.g. from a |
|
| 77 |
+[cron][] job). The format is [tab-separated values][], human and machine |
|
| 78 |
+readable and suitable for use with spreadsheet software. |
|
| 79 |
+ |
|
| 80 |
+Lastly, the expected pay, after taxes (which rate can be given with `--tax`, |
|
| 81 |
+defaults to `0.3`), for the months where data is available is printed, in |
|
| 82 |
+reverse chronological order. |
|
| 83 |
+ |
|
| 84 |
+[cron]: https://en.wikipedia.org/wiki/Cron |
|
| 85 |
+[tab-separated values]: https://en.wikipedia.org/wiki/Tab-separated_values |
|
| 86 |
+ |
|
| 87 |
+### `personnel` command |
|
| 88 |
+ |
|
| 89 |
+Prints the name, telephone number and position in the organization separated by |
|
| 90 |
+tab, one person per row, by parsing the table "Användare" on the page |
|
| 91 |
+"Användare". |
|
| 92 |
+ |
|
| 93 |
+Only tested on accounts that have the "Leveransplanerare" access permissions! |
|
| 94 |
+ |
|
| 95 |
+### `report` command |
|
| 96 |
+ |
|
| 97 |
+Prints statistics of a given report. |
|
| 98 |
+ |
|
| 99 |
+Only tested on accounts that have the "Leveransplanerare" access permissions! |
|
| 8 | 100 |
|
| 9 | 101 |
## Install |
| 10 | 102 |
|
| ... | ... |
@@ -6,6 +6,68 @@ |
| 6 | 6 |
[scrape]: https://en.wikipedia.org/wiki/Web_scraping |
| 7 | 7 |
[intranet.bygglogistik.se]: http://intranet.bygglogistik.se |
| 8 | 8 |
|
| 9 |
+## Install |
|
| 10 |
+ |
|
| 11 |
+Make sure [Python is installed][Python download], [`pip`][] is available and |
|
| 12 |
+the [`pip`][], [`setuptools`][] and [`wheel`][] packages are up to date: |
|
| 13 |
+ |
|
| 14 |
+```sh |
|
| 15 |
+python3 -m pip install --user --upgrade pip setuptools wheel |
|
| 16 |
+``` |
|
| 17 |
+ |
|
| 18 |
+Reference: [Python Packaging User Guide: Requirements for Installing |
|
| 19 |
+Packages][]. |
|
| 20 |
+ |
|
| 21 |
+[Python download]: https://python.org/download |
|
| 22 |
+[`pip`]: https://pip.readthedocs.io |
|
| 23 |
+[`setuptools`]: https://setuptools.readthedocs.io |
|
| 24 |
+[`wheel`]: https://wheel.readthedocs.io |
|
| 25 |
+[Python Packaging User Guide: Requirements for Installing Packages]: https://packaging.python.org/tutorials/installing-packages/#requirements-for-installing-packages |
|
| 26 |
+ |
|
| 27 |
+### With [`pipx`][], for users |
|
| 28 |
+ |
|
| 29 |
+Make sure [`pipx`][] is installed: |
|
| 30 |
+ |
|
| 31 |
+```sh |
|
| 32 |
+python3 -m pip install --user pipx |
|
| 33 |
+``` |
|
| 34 |
+ |
|
| 35 |
+Install `bygglogistik-utils`: |
|
| 36 |
+ |
|
| 37 |
+```sh |
|
| 38 |
+pipx install "git+https://git.rcrnstn.net/rcrnstn/bygglogistik-utils" |
|
| 39 |
+``` |
|
| 40 |
+ |
|
| 41 |
+`bygglogistik-utils` should now be in your [`PATH`][] (if not, run `python3 -m |
|
| 42 |
+pipx ensurepath`). |
|
| 43 |
+ |
|
| 44 |
+Reference: [Python Packaging User Guide: Installing stand alone command line |
|
| 45 |
+tools][]. |
|
| 46 |
+ |
|
| 47 |
+[`pipx`]: https://pipxproject.github.io/pipx/ |
|
| 48 |
+[`PATH`]: https://en.wikipedia.org/wiki/PATH_(variable) |
|
| 49 |
+[Python Packaging User Guide: Installing stand alone command line tools]: https://packaging.python.org/guides/installing-stand-alone-command-line-tools/ |
|
| 50 |
+ |
|
| 51 |
+### Into [`venv`][], for developers |
|
| 52 |
+ |
|
| 53 |
+Clone and install into a repository [`venv`][] virtual environment: |
|
| 54 |
+ |
|
| 55 |
+```sh |
|
| 56 |
+git clone "https://git.rcrnstn.net/rcrnstn/bygglogistik-utils" |
|
| 57 |
+cd "bygglogistik-utils" |
|
| 58 |
+python3 -m venv .venv |
|
| 59 |
+. .venv/bin/activate |
|
| 60 |
+python3 -m pip install --editable . |
|
| 61 |
+``` |
|
| 62 |
+ |
|
| 63 |
+`bygglogistik-utils` should now be in your (virtual environment) [`PATH`][]. |
|
| 64 |
+ |
|
| 65 |
+Reference: [Python Packaging User Guide: Installing packages using pip and |
|
| 66 |
+virtual environments][]. |
|
| 67 |
+ |
|
| 68 |
+[`venv`]: https://docs.python.org/3/library/venv.html |
|
| 69 |
+[Python Packaging User Guide: Installing packages using pip and virtual environments]: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/ |
|
| 70 |
+ |
|
| 9 | 71 |
## License |
| 10 | 72 |
|
| 11 | 73 |
Licensed under the [ISC License][] unless otherwise noted, see the |
| ... | ... |
@@ -5,3 +5,11 @@ |
| 5 | 5 |
[`bygglogistik-utils`]: https://git.rcrnstn.net/rcrnstn/bygglogistik-utils |
| 6 | 6 |
[scrape]: https://en.wikipedia.org/wiki/Web_scraping |
| 7 | 7 |
[intranet.bygglogistik.se]: http://intranet.bygglogistik.se |
| 8 |
+ |
|
| 9 |
+## License |
|
| 10 |
+ |
|
| 11 |
+Licensed under the [ISC License][] unless otherwise noted, see the |
|
| 12 |
+[`LICENSE`][] file. |
|
| 13 |
+ |
|
| 14 |
+[ISC license]: https://choosealicense.com/licenses/isc/ |
|
| 15 |
+[`LICENSE`]: LICENSE |
| 1 | 1 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,7 @@ |
| 1 |
+# [`bygglogistik-utils`][] |
|
| 2 |
+ |
|
| 3 |
+[Scrape][] [intranet.bygglogistik.se][]. |
|
| 4 |
+ |
|
| 5 |
+[`bygglogistik-utils`]: https://git.rcrnstn.net/rcrnstn/bygglogistik-utils |
|
| 6 |
+[scrape]: https://en.wikipedia.org/wiki/Web_scraping |
|
| 7 |
+[intranet.bygglogistik.se]: http://intranet.bygglogistik.se |