auto-reference-generator 1.0.0__tar.gz → 1.3.5__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/.github/workflows/codeql.yml +31 -4
  2. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/.github/workflows/pypi-publish.yml +1 -1
  3. auto_reference_generator-1.3.5/.github/workflows/python-tests.yml +30 -0
  4. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/.gitignore +1 -0
  5. auto_reference_generator-1.3.5/PKG-INFO +344 -0
  6. auto_reference_generator-1.3.5/README.md +319 -0
  7. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/auto_reference_generator/cli.py +80 -12
  8. auto_reference_generator-1.3.5/auto_reference_generator/common.py +209 -0
  9. auto_reference_generator-1.3.5/auto_reference_generator/hash.py +49 -0
  10. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/auto_reference_generator/options/options.properties +5 -0
  11. auto_reference_generator-1.0.0/auto_reference_generator/classification_generator.py → auto_reference_generator-1.3.5/auto_reference_generator/reference_generator.py +229 -238
  12. auto_reference_generator-1.3.5/auto_reference_generator.egg-info/PKG-INFO +344 -0
  13. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/auto_reference_generator.egg-info/SOURCES.txt +12 -2
  14. auto_reference_generator-1.3.5/auto_reference_generator.egg-info/requires.txt +11 -0
  15. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/pyproject.toml +19 -5
  16. auto_reference_generator-1.3.5/pytest.ini +35 -0
  17. auto_reference_generator-1.3.5/samples/auto_reference_generator_AutoRef.xlsx +0 -0
  18. auto_reference_generator-1.3.5/samples/auto_reference_generator_AutoRef_from_json.xlsx +0 -0
  19. auto_reference_generator-1.3.5/samples/sample_json_dict.json +1 -0
  20. auto_reference_generator-1.3.5/tests/test_common.py +28 -0
  21. auto_reference_generator-1.3.5/tests/test_hash.py +27 -0
  22. auto_reference_generator-1.3.5/tests/test_reference_generator.py +42 -0
  23. auto_reference_generator-1.3.5/tests/test_reference_generator_integration.py +62 -0
  24. auto_reference_generator-1.3.5/tests/test_reference_loop_and_keywords.py +89 -0
  25. auto_reference_generator-1.0.0/PKG-INFO +0 -15
  26. auto_reference_generator-1.0.0/README.md +0 -274
  27. auto_reference_generator-1.0.0/auto_reference_generator/common.py +0 -165
  28. auto_reference_generator-1.0.0/auto_reference_generator/hash.py +0 -27
  29. auto_reference_generator-1.0.0/auto_reference_generator.egg-info/PKG-INFO +0 -15
  30. auto_reference_generator-1.0.0/auto_reference_generator.egg-info/requires.txt +0 -2
  31. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/LICENSE.md +0 -0
  32. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/assets/AccessionPreview.png +0 -0
  33. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/assets/HashPreview.png +0 -0
  34. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/assets/ReferencesPreview.png +0 -0
  35. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/assets/SpreadGen.png +0 -0
  36. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/assets/SpreadPreview.png +0 -0
  37. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/assets/metaFolder.png +0 -0
  38. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/assets/sample_from_dict.json +0 -0
  39. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/auto_reference_generator/__init__.py +0 -0
  40. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/auto_reference_generator.egg-info/dependency_links.txt +0 -0
  41. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/auto_reference_generator.egg-info/entry_points.txt +0 -0
  42. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/auto_reference_generator.egg-info/top_level.txt +0 -0
  43. {auto_reference_generator-1.0.0 → auto_reference_generator-1.3.5}/setup.cfg +0 -0
@@ -14,9 +14,22 @@ name: "CodeQL"
14
14
  on:
15
15
  push:
16
16
  branches: [ master ]
17
+ # avoid running on doc-only / asset-only changes
18
+ paths-ignore:
19
+ - 'README.md'
20
+ - 'docs/**'
21
+ - 'assets/**'
22
+ - '.github/**'
17
23
  pull_request:
18
24
  # The branches below must be a subset of the branches above
19
25
  branches: [ master ]
26
+ paths-ignore:
27
+ - 'README.md'
28
+ - 'docs/**'
29
+ - 'assets/**'
30
+ - '.github/**'
31
+ # allow manual runs
32
+ workflow_dispatch: {}
20
33
  schedule:
21
34
  - cron: '20 10 * * 6'
22
35
 
@@ -24,6 +37,9 @@ jobs:
24
37
  analyze:
25
38
  name: Analyze
26
39
  runs-on: ubuntu-latest
40
+ concurrency:
41
+ group: codeql-scan-${{ github.ref }}
42
+ cancel-in-progress: true
27
43
  permissions:
28
44
  actions: read
29
45
  contents: read
@@ -39,11 +55,22 @@ jobs:
39
55
 
40
56
  steps:
41
57
  - name: Checkout repository
42
- uses: actions/checkout@v2
58
+ uses: actions/checkout@v4
59
+
60
+ - name: Set up Python (improves CodeQL context for Python projects)
61
+ uses: actions/setup-python@v4
62
+ with:
63
+ python-version: '3.x'
64
+ cache: 'pip'
65
+
66
+ - name: Install dev dependencies (optional)
67
+ run: |
68
+ python -m pip install --upgrade pip
69
+ if [ -f pyproject.toml ]; then pip install -e '.[dev]' || true; fi
43
70
 
44
71
  # Initializes the CodeQL tools for scanning.
45
72
  - name: Initialize CodeQL
46
- uses: github/codeql-action/init@v2
73
+ uses: github/codeql-action/init@v4
47
74
  with:
48
75
  languages: ${{ matrix.language }}
49
76
  # If you wish to specify custom queries, you can do so here or in a config file.
@@ -54,7 +81,7 @@ jobs:
54
81
  # Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
55
82
  # If this step fails, then you should remove it and run the build manually (see below)
56
83
  - name: Autobuild
57
- uses: github/codeql-action/autobuild@v2
84
+ uses: github/codeql-action/autobuild@v4
58
85
 
59
86
  # ℹ️ Command-line programs to run using the OS shell.
60
87
  # 📚 https://git.io/JvXDl
@@ -68,4 +95,4 @@ jobs:
68
95
  # make release
69
96
 
70
97
  - name: Perform CodeQL Analysis
71
- uses: github/codeql-action/analyze@v2
98
+ uses: github/codeql-action/analyze@v4
@@ -37,7 +37,7 @@ jobs:
37
37
  runs-on: ubuntu-latest
38
38
  environment:
39
39
  name: pypi
40
- url: https://pypi.org/p/auto_reference_generator # Replace <package-name> with your PyPI project name
40
+ url: https://pypi.org/p/auto-reference-generator # Replace <package-name> with your PyPI project name
41
41
  permissions:
42
42
  id-token: write # IMPORTANT: mandatory for trusted publishing
43
43
 
@@ -0,0 +1,30 @@
1
+ name: Tests
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ build:
11
+ runs-on: ubuntu-latest
12
+ strategy:
13
+ matrix:
14
+ python-version: ['3.10', '3.11', '3.12', '3.13']
15
+
16
+ steps:
17
+ - uses: actions/checkout@v4
18
+ - name: Set up Python ${{ matrix.python-version }}
19
+ uses: actions/setup-python@v4
20
+ with:
21
+ python-version: ${{ matrix.python-version }}
22
+
23
+ - name: Install dependencies
24
+ run: |
25
+ python -m pip install --upgrade pip
26
+ python -m pip install -e ".[dev,addex]"
27
+
28
+ - name: Run tests
29
+ run: |
30
+ python -m pytest -v
@@ -1,6 +1,7 @@
1
1
  __pycache__
2
2
  dist/
3
3
  .venv
4
+ .linuxvenv
4
5
  .vscode
5
6
  auto_reference_generator.egg-info/
6
7
  build/
@@ -0,0 +1,344 @@
1
+ Metadata-Version: 2.4
2
+ Name: auto_reference_generator
3
+ Version: 1.3.5
4
+ Summary: A tool for archivist's to automate the generation of references for digital files
5
+ Author-email: Christopher Prince <c.pj.prince@gmail.com>
6
+ License-Expression: Apache-2.0
7
+ Project-URL: Homepage, https://github.com/CPJPRINCE/auto_reference_generator
8
+ Project-URL: Issues, https://github.com/CPJPRINCE/auto_reference_generator/issues
9
+ Keywords: archiving,archives,digital archiving,references,automatic archival reference generator
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Topic :: System :: Archiving
13
+ Description-Content-Type: text/markdown
14
+ License-File: LICENSE.md
15
+ Requires-Dist: pandas
16
+ Requires-Dist: openpyxl
17
+ Requires-Dist: tqdm
18
+ Provides-Extra: addex
19
+ Requires-Dist: lxml; extra == "addex"
20
+ Requires-Dist: odfpy; extra == "addex"
21
+ Provides-Extra: dev
22
+ Requires-Dist: pytest>=7.0; extra == "dev"
23
+ Requires-Dist: pytest-cov>=4.0; extra == "dev"
24
+ Dynamic: license-file
25
+
26
+ # Auto Reference Generator
27
+
28
+ A small python programme to generate hieracrchical archival reference for files and directories and export the results to a spreadsheet.
29
+
30
+ Badges: PyPI | CI | Coverage | License
31
+
32
+ ## Quick Start
33
+ Install:
34
+ ```
35
+ pip install -U auto_reference_generator
36
+ ```
37
+ Or download portable version.
38
+
39
+ Run:
40
+ ```
41
+ auto_ref /path/to/root -p PREFIX -o /path/to/output
42
+ ```
43
+
44
+ Generates a `meta/` folder with output `root_AutoRef.xlsx`
45
+
46
+ To use the portable version navigate to the Downloaded then run with:
47
+ ```
48
+ .\auto_ref.exe .\path\to\root
49
+ ```
50
+
51
+ ## Version & Package info
52
+
53
+ Python Version:
54
+ Python Version 3.10+ is recommended. Earlier versions may work but are not tested.
55
+
56
+ Additional Packages:
57
+ - pandas (required)
58
+ - openpyxl (required - spreadsheet exports)
59
+ - pyodf (ods export)
60
+ - lxml (xml export)
61
+ - tqdm
62
+ To install:
63
+
64
+ ```
65
+ pip install pandas openpyxl pyodf lxml tqdm
66
+ ```
67
+ Portable version includes
68
+
69
+ ## Why use this tool?
70
+
71
+ This tool is designed for archivist's cataloguing large amounts of Digital Records at a time.
72
+
73
+ It's platform independent tested functioning on Windows and Linux (untested on MacOS).
74
+
75
+ ## Features:
76
+
77
+ - Hierachical reference generation with customisatible (Prefixes/Suffixes/Delimiters/Starting ref).
78
+ - 'Level' identification and limiting.
79
+ - Keyword filtering - replacing Numericals with specified keywords (intials, first letter, JSON map)
80
+ - Logged removal of empty directories.
81
+ - An Accession / Running Number mode.
82
+ - Fixity Generation
83
+ - Exports: xslx (Default), csv, ods (requires pyodf), json or xml (requires lxml).
84
+ - Integration with Opex Manifest Generator [*\*Shameless Self promotion\**.](https://github.com/CPJPRINCE/opex_manifest_generator/)
85
+
86
+ ## Basic Usage / Examples
87
+
88
+ - Basic: `auto_ref /path/to/root`
89
+ - Prefix: `auto_ref /path/to/root -p PREFIX`
90
+ - Suffix: `auto_ref /path/to/root -s SUFFIX`
91
+ - Delimiter: `auto_ref /path/to/root -dlm "-"`
92
+ - Accession: `auto_ref /path/to/root -acc file`
93
+ - Fixity: `auto_ref /path/to/root -fx MD5`
94
+ - Format: `auto_ref /path/to/root -fmt csv`
95
+ - Remove Empty `auto_ref /path/to/root --remove-empty`
96
+ - Output: `auto_ref /path/to/root -o /path/to/output`
97
+ - Include Hidden: `auto_ref /path/to/root --hidden`
98
+
99
+ These options can be combined in an.
100
+
101
+ ## Output
102
+
103
+ Expected ouput is like so:
104
+
105
+ ![SpreadPreview](assets/SpreadPreview.png)
106
+
107
+ This includes a preset of metadata:
108
+ Including: FullName, RelativeName, BaseName, Size, Modified, Ref_Section Level, Parent, Archive_Reference,
109
+
110
+ The reference will by default be generated to the `Archive_Reference` column:
111
+
112
+ ![ReferencePreview](assets/ReferencesPreview.png)
113
+
114
+ ## Structure of References
115
+
116
+ Usage with Prefix `ARC`.
117
+ ```
118
+ Folder Reference
119
+ >Root ARC
120
+ --->Folder 1 ARC/1
121
+ ------>Sub Folder 1 ARC/1/1
122
+ --------->File 1 ARC/1/1/1
123
+ --------->File 2 ARC/1/1/2
124
+ ------>Sub Folder 2 ARC/1/2
125
+ --------->File 3 ARC/1/2/1
126
+ --------->File 4 ARC/1/2/2
127
+ --->Folder 2 ARC/2
128
+ ------>Sub Folder 3 ARC/2/1
129
+ --------->File 5 ARC/2/2
130
+ --->File 6 ARC/3
131
+ ```
132
+
133
+ Files and Folders can coexist at the same level. Without a prefix the root reference defaults to 0:
134
+
135
+ ```
136
+ >Root 0
137
+ --->Folder 1
138
+ ------>Sub Folder 1/1
139
+ --------->File 1/1/1
140
+ --------->File2 1/1/2
141
+ ------>File3 1/2
142
+
143
+ ```
144
+ Prefixes can be set to any point in an Hierachy.
145
+
146
+ ## Advanced Options
147
+
148
+ ### Accession mode
149
+
150
+ An alternative method of code generation is based on an 'accession number'/running number pattern. Each file or folder will be given a running number regardless of depth.
151
+
152
+ Example output running Accession in "File" Mode:
153
+ ```
154
+ > Root ACC-Dir
155
+ ---> Folder 1 ACC-Dir
156
+ ------> File 1 ACC-1
157
+ ------> File 2 ACC-2
158
+ ---> File 3 ACC-3
159
+ ---> Folder 2 ACC-Dir
160
+ ------> Sub-Folder ACC-Dir
161
+ ---------> File 4 ACC-4
162
+ ```
163
+
164
+ To run:
165
+
166
+ `auto_ref "/path/to/root" -acc file -accp "ACC"`
167
+
168
+ The available modes are for `file, dir, all`. Output will be to an additiona `Accession_Reference` column
169
+
170
+ ![AccessionPReview](assets/AccessionPreview.png)
171
+
172
+
173
+ ### Clear Empty Directories
174
+
175
+ Running `auto_ref /path/to/root --remove-empty` automatically remove any empty directories. A plain text log of the removed directories will be saved to `meta/`.
176
+
177
+ ### Fixity
178
+
179
+ To run a fixity and save to the output: `auto_ref /path/to/root -fx ALGORITHM` This will default to using the SHA-1 algorithm. MD5, SHA-1, SHA-256 and SHA-512 are supported.
180
+
181
+ ![HashPreview](assets/HashPreview.png)
182
+
183
+ ### Level Limit
184
+
185
+ Set a level limit to stop generating referencing at: `auto_ref /path/to/root -l 5` will stop generating references 5 levels below root.
186
+
187
+ ### Skip
188
+
189
+ If you want to generate a spreadsheet without a reference code you can run: `auto_ref /path/to/root --skip`
190
+
191
+ ### Options File
192
+
193
+ You can customise the program by creating an 'options file' using the `--options-file` option. This allows for customisation of the column headers and the programs defaults.
194
+
195
+ Options given as:
196
+ ```
197
+ [options]
198
+
199
+ INDEX_FIELD = FullName #Sets which field to use for index.
200
+
201
+ PATH_FIELD = FullName
202
+ RELATIVE_FIELD = RelativeName
203
+ PARENT_FIELD = Parent
204
+ PARENT_REF = Parent_Ref
205
+ REFERENCE_FIELD = Archive_Reference
206
+ REF_SECTION = Ref_Section
207
+ ACCESSION_FIELD = Accession_Reference
208
+ LEVEL_FIELD = Level
209
+ ...
210
+ ```
211
+
212
+ ### Keywords
213
+
214
+ To use Keywords: `auto_ref /path/to/root -key Keyword1 Keyword2 Keyword3 ... -keym intialise` The keywords will replace the reference number to all matches of the keyword. The way the replacement is made is determined by the `-keym / --keyword-mode`.
215
+
216
+ Keyword Modes:
217
+ - `intialise` Uses the intials of the words. `Department of Justice` becomes `DOJ`. Singluar words use first x amount of letters.
218
+ - `firstletters` uses the first x amount of letters.`Department of Justices` becomes `DEP`.
219
+ - `from_json` can create a Python Dictionary in a JSON file and set KEYWORD to that file. Will replace all keys with given value. Run like so: `auto_ref /path/to/root -key /path/to/json.json`.
220
+ - JSON Dict written like so: `{'keyword':'value','keyword2','value2',...}`
221
+
222
+ ## Full Options:
223
+
224
+ (Note to self add in argparse to md...)
225
+
226
+ The below covers the full range of options. This may not be up to date.
227
+ For up to date options use the `-h` option to show dialog:
228
+
229
+ ```
230
+ Options:
231
+ -h, --help Show Help dialog
232
+
233
+ -p, --prefix Replace Root 0 with specified prefix [string]
234
+ Is added to all references
235
+
236
+ -s --suffix Add a suffix to references [string]
237
+
238
+ --suffix-options Set whether to apply to files, {apply_to_files,apply_to_folders,
239
+ folders,or to all apply_to_all}
240
+ default is to apply_to_files.
241
+
242
+ -l --level-limit Set whether to limit generation to [int]
243
+ a specific level.
244
+ Note generated references may have
245
+ extra delimiter.
246
+
247
+ -dlm --delimiter Set to change the default delimiter [string]
248
+
249
+ -acc, --accession Run in "Accession Mode", this will {Dir,File,
250
+ generate a running number of either All}
251
+ Files, directories, or Both
252
+
253
+ -accp, --acc-prefix Set the Prefix to append onto the running [boolean]
254
+ number generated in "Accession Mode"
255
+
256
+ -fx --fixity Generate fixity codes for files {MD5, SHA-1,
257
+ SHA-256, SHA-512}
258
+
259
+ -hid --hidden Include Hidden directories and files in [boolean]
260
+ generation.
261
+
262
+ --remove-empty Will remove all Empty Directories from [boolean]
263
+ within a given folder, not including them
264
+ in the Reference Generation.
265
+ A simply Text list of removed folders is
266
+ then generated to the output directory.
267
+
268
+ -str, --start-ref Set the number to start the Reference [int]
269
+ generation from.
270
+
271
+ -o, --output Set the directory to export the spreadsheet to. [string]
272
+
273
+ --disable-meta-dir Set whether to generate a "meta" directory, [boolean]
274
+ to export CSV / Excel file to.
275
+ Default behavior will be to create a directory,
276
+ using this option will disable it.
277
+
278
+ -skp --skip Skip running the Auto Reference process, [boolean]
279
+ will generate a spreadsheet but not
280
+ an Archival Reference
281
+
282
+ -fmt, --format Set export format. Will require {xlsx,csv,ods,dict,xml,json}
283
+ appropriate modules in Python.
284
+ ods - PyODF
285
+ xlsx - OpenPyXL
286
+ xml - lxml
287
+ Defaults to xlsx.
288
+
289
+ -key --keywords Set keywords to replace numericals with [string|path]
290
+ alphanumerical characters
291
+ Can be single word or
292
+ list: 'written,like,this'
293
+ Or path to a JSON file containing a dict
294
+
295
+ Keywords only currently act upon folders
296
+ and not files.
297
+
298
+ -keym -keywords-mode Set way to replace: {initialise,first_letters,from_json}
299
+ initialise: My New Folder > MNF
300
+ first_letters: My New Folder > MYF
301
+ from_json: Imports
302
+ Requires to have a Json file with a
303
+ dictionary of words to replace:
304
+ {'Word':'Replacement',
305
+ 'SecondWord':'2ndReplacement}
306
+
307
+ --keywords-retain- Set whether to continue reference numbering [bool]
308
+ order If not used keywords don't 'count' towards
309
+ additional references.
310
+ IE if the keyword you are replacing is
311
+ be reference number: 2, this is moved
312
+ to what would originally be number 3.
313
+ Retaining the order means, this scheme is
314
+ maintained: IE 3 is still 3, and 2 is skipped
315
+
316
+ --keywords-case- Set to enable case-sensitivity for keyword [bool]
317
+ sensitivity matches. Default is cases are not sensitive.
318
+
319
+ --keywords-abbreviation Set the number of characters to abbreviate to [int]
320
+ -number Only for first_letters mode.
321
+
322
+ --sort-by Set the sorting method: folders_first, sorts [folders_first|alphabetically]
323
+ folders first. Alphabetically, you can guess.
324
+ Ignores folders.
325
+
326
+
327
+
328
+ ```
329
+
330
+ ## Troubleshooting
331
+
332
+ - On Windows ensure that your root folder does not end in a `\`.
333
+ - The `meta/` folder will always be ignored.
334
+
335
+
336
+ ## Future Developments
337
+
338
+ - ~~Level Limitations to allow for "group references"~~ - Added!
339
+ - ~~Generating reference's which use alphabetic characters~~ - Added!
340
+ - Physical Level
341
+
342
+ ## Contributing
343
+
344
+ I welcome further contributions and feedback.