Browse code

Replace third party `docopt` with `argparse`

Robert Cranston authored on 09/05/2025 15:03:38
Showing 1 changed files
... ...
@@ -10,23 +10,18 @@ Parse [Raspberry Pi revision codes][].
10 10
 `raspi-revcode --help`:
11 11
 
12 12
 ```
13
-usage:
14
-  raspi-revcode [<code>]
15
-  raspi-revcode -h|--help
16
-  raspi-revcode --version
13
+usage: raspi_revcode.py [-h] [--version] [<code>]
17 14
 
18 15
 Parse Raspberry Pi revision codes.
19 16
 
20 17
 positional arguments:
21
-  <code>
22
-    A hexadecimal revision code to parse. If not given, '/proc/cpuinfo' will be
23
-    used to get the revision code of the current device.
18
+  <code>      A hexadecimal revision code to parse. If not given,
19
+              '/proc/cpuinfo' will be used to get the revision code of the
20
+              current device.
24 21
 
25 22
 optional arguments:
26
-  -h, --help
27
-    Show this help message and exit.
28
-  --version
29
-    Show program's version number and exit.
23
+  -h, --help  show this help message and exit
24
+  --version   show program's version number and exit
30 25
 ```
31 26
 
32 27
 ## Examples
... ...
@@ -72,6 +67,14 @@ Overvoltage  : Overvoltage disallowed
72 67
 
73 68
 ## Install
74 69
 
70
+`raspi-revcode` depends only on the Python standard library which means that,
71
+if [Python is installed][Python download], it can run be as a standalone script
72
+without installation:
73
+
74
+```sh
75
+./raspi_revcode.py
76
+```
77
+
75 78
 ### Prerequisites
76 79
 
77 80
 Make sure [Python is installed][Python download], [`pip`][] is available and
Browse code

Add implementation

Robert Cranston authored on 29/10/2023 05:38:08
Showing 1 changed files
... ...
@@ -5,6 +5,71 @@ Parse [Raspberry Pi revision codes][].
5 5
 [`raspi-revcode`]: https://git.rcrnstn.net/rcrnstn/raspi-revcode
6 6
 [Raspberry Pi revision codes]: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-revision-codes
7 7
 
8
+## Usage
9
+
10
+`raspi-revcode --help`:
11
+
12
+```
13
+usage:
14
+  raspi-revcode [<code>]
15
+  raspi-revcode -h|--help
16
+  raspi-revcode --version
17
+
18
+Parse Raspberry Pi revision codes.
19
+
20
+positional arguments:
21
+  <code>
22
+    A hexadecimal revision code to parse. If not given, '/proc/cpuinfo' will be
23
+    used to get the revision code of the current device.
24
+
25
+optional arguments:
26
+  -h, --help
27
+    Show this help message and exit.
28
+  --version
29
+    Show program's version number and exit.
30
+```
31
+
32
+## Examples
33
+
34
+The following example shows calling `raspi-revcode` from the shell, and the
35
+produced output:
36
+
37
+```
38
+$ raspi-revcode 0012
39
+Type         : A+
40
+Revision     : 1.1
41
+Memory size  : 256MB
42
+Manufacturer : Sony UK
43
+New flag     : Old-style revision
44
+Warranty bit : Warranty is intact
45
+
46
+$ raspi-revcode 900021
47
+Revision     : 1.1
48
+Type         : A+
49
+Processor    : BCM2835
50
+Manufacturer : Sony UK
51
+Memory size  : 512MB
52
+New flag     : New-style revision
53
+Warranty bit : Warranty is intact
54
+OTP Read     : OTP reading allowed
55
+OTP Program  : OTP programming allowed
56
+Overvoltage  : Overvoltage allowed
57
+
58
+$ raspi-revcode ffffffff
59
+Revision     : 1.15
60
+Type         : <UNEXPECTED 0xff>
61
+Processor    : <UNEXPECTED 0xf>
62
+Manufacturer : <UNEXPECTED 0xf>
63
+Memory size  : <UNEXPECTED 0x7>
64
+New flag     : New-style revision
65
+Unused       : <UNEXPECTED 0x1>
66
+Warranty bit : Warranty has been voided by overclocking
67
+Unused       : <UNEXPECTED 0x7>
68
+OTP Read     : OTP reading disallowed
69
+OTP Program  : OTP programming disallowed
70
+Overvoltage  : Overvoltage disallowed
71
+```
72
+
8 73
 ## Install
9 74
 
10 75
 ### Prerequisites
Browse code

Add installation

Robert Cranston authored on 29/10/2023 05:19:28
Showing 1 changed files
... ...
@@ -5,6 +5,70 @@ Parse [Raspberry Pi revision codes][].
5 5
 [`raspi-revcode`]: https://git.rcrnstn.net/rcrnstn/raspi-revcode
6 6
 [Raspberry Pi revision codes]: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-revision-codes
7 7
 
8
+## Install
9
+
10
+### Prerequisites
11
+
12
+Make sure [Python is installed][Python download], [`pip`][] is available and
13
+the [`pip`][], [`setuptools`][] and [`wheel`][] packages are up to date:
14
+
15
+```sh
16
+python3 -m pip install --user --upgrade pip setuptools wheel
17
+```
18
+
19
+Reference: [Python Packaging User Guide: Requirements for Installing
20
+Packages][].
21
+
22
+[Python download]: https://python.org/download
23
+[`pip`]: https://pip.readthedocs.io
24
+[`setuptools`]: https://setuptools.readthedocs.io
25
+[`wheel`]: https://wheel.readthedocs.io
26
+[Python Packaging User Guide: Requirements for Installing Packages]: https://packaging.python.org/tutorials/installing-packages/#requirements-for-installing-packages
27
+
28
+### With [`pipx`][], for users
29
+
30
+Make sure [`pipx`][] is installed:
31
+
32
+```sh
33
+python3 -m pip install --user pipx
34
+```
35
+
36
+Install `raspi-revcode`:
37
+
38
+```sh
39
+pipx install "git+https://git.rcrnstn.net/rcrnstn/raspi-revcode"
40
+```
41
+
42
+`raspi-revcode` should now be in your [`PATH`][] (if not, run `python3 -m pipx
43
+ensurepath`).
44
+
45
+Reference: [Python Packaging User Guide: Installing stand alone command line
46
+tools][].
47
+
48
+[`pipx`]: https://pipxproject.github.io/pipx/
49
+[`PATH`]: https://en.wikipedia.org/wiki/PATH_(variable)
50
+[Python Packaging User Guide: Installing stand alone command line tools]: https://packaging.python.org/guides/installing-stand-alone-command-line-tools/
51
+
52
+### Into [`venv`][], for developers
53
+
54
+Clone and install into a repository [`venv`][] virtual environment:
55
+
56
+```sh
57
+git clone "https://git.rcrnstn.net/rcrnstn/raspi-revcode"
58
+cd "raspi-revcode"
59
+python3 -m venv .venv
60
+. .venv/bin/activate
61
+python3 -m pip install --editable .
62
+```
63
+
64
+`raspi-revcode` should now be in your (virtual environment) [`PATH`][].
65
+
66
+Reference: [Python Packaging User Guide: Installing packages using pip and
67
+virtual environments][].
68
+
69
+[`venv`]: https://docs.python.org/3/library/venv.html
70
+[Python Packaging User Guide: Installing packages using pip and virtual environments]: https://packaging.python.org/guides/installing-using-pip-and-virtual-environments/
71
+
8 72
 ## License
9 73
 
10 74
 Licensed under the [ISC License][] unless otherwise noted, see the
Browse code

Add license

Robert Cranston authored on 29/10/2023 05:15:53
Showing 1 changed files
... ...
@@ -4,3 +4,11 @@ Parse [Raspberry Pi revision codes][].
4 4
 
5 5
 [`raspi-revcode`]: https://git.rcrnstn.net/rcrnstn/raspi-revcode
6 6
 [Raspberry Pi revision codes]: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-revision-codes
7
+
8
+## License
9
+
10
+Licensed under the [ISC License][] unless otherwise noted, see the
11
+[`LICENSE`][] file.
12
+
13
+[ISC License]: https://choosealicense.com/licenses/isc
14
+[`LICENSE`]: LICENSE
Browse code

Add readme

Robert Cranston authored on 29/10/2023 05:15:45
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,6 @@
1
+# [`raspi-revcode`][]
2
+
3
+Parse [Raspberry Pi revision codes][].
4
+
5
+[`raspi-revcode`]: https://git.rcrnstn.net/rcrnstn/raspi-revcode
6
+[Raspberry Pi revision codes]: https://www.raspberrypi.com/documentation/computers/raspberry-pi.html#raspberry-pi-revision-codes