datoso-seed-whdload 1.0.0__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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023 Lacides Miranda
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.1
2
+ Name: datoso_seed_whdload
3
+ Version: 1.0.0
4
+ Summary: Python command line tool to download and organize your Rom Dat files.
5
+ Author-email: Lacides Miranda <laromicas@hotmail.com>
6
+ License: MIT License
7
+ Project-URL: Source Code, https://github.com/laromicas/datoso_seed_whdload
8
+ Keywords: emulators,roms
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: System :: Emulators
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+
19
+ ![Datoso](https://github.com/laromicas/datoso/blob/master/bearlogo.png)
20
+
21
+ # Datoso Seed Whdload
22
+
23
+ Datoso is a WIP Python command line tool to download and organize your Dat Roms.
24
+ As today the tool supports dat-omatic, redump, and translated-english dats.
25
+ It merges all the dats in a tree folder structure thought to use with Emulators rather than dats.
26
+ The dat file format must be compatible with [ROMVault](https://www.romvault.com/).
27
+
28
+ WHDLoad is a collection of Amiga Roms
29
+
30
+ ## Installation
31
+
32
+ Datoso requires python 3.10+.
33
+
34
+ Use pip (recommended to use a virtual environment):
35
+
36
+ ``` bash
37
+ # Install datoso base (doesn't do much without real plugins)
38
+ pip install datoso_seed_whdload
39
+
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ Check [Datoso](https://github.com/laromicas/datoso) for usage.
45
+
46
+
47
+ ## TODO
48
+
49
+ - Tests
50
+
51
+ ## Contributing
52
+
53
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
54
+ Please make sure to update tests as appropriate.
55
+
56
+ ## License
57
+
58
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,40 @@
1
+ ![Datoso](https://github.com/laromicas/datoso/blob/master/bearlogo.png)
2
+
3
+ # Datoso Seed Whdload
4
+
5
+ Datoso is a WIP Python command line tool to download and organize your Dat Roms.
6
+ As today the tool supports dat-omatic, redump, and translated-english dats.
7
+ It merges all the dats in a tree folder structure thought to use with Emulators rather than dats.
8
+ The dat file format must be compatible with [ROMVault](https://www.romvault.com/).
9
+
10
+ WHDLoad is a collection of Amiga Roms
11
+
12
+ ## Installation
13
+
14
+ Datoso requires python 3.10+.
15
+
16
+ Use pip (recommended to use a virtual environment):
17
+
18
+ ``` bash
19
+ # Install datoso base (doesn't do much without real plugins)
20
+ pip install datoso_seed_whdload
21
+
22
+ ```
23
+
24
+ ## Usage
25
+
26
+ Check [Datoso](https://github.com/laromicas/datoso) for usage.
27
+
28
+
29
+ ## TODO
30
+
31
+ - Tests
32
+
33
+ ## Contributing
34
+
35
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
36
+ Please make sure to update tests as appropriate.
37
+
38
+ ## License
39
+
40
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,38 @@
1
+ [build-system]
2
+ requires = ["setuptools~=67.6", "wheel~=0.40.0"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+
6
+ [project]
7
+ name = "datoso_seed_whdload"
8
+ description = "Python command line tool to download and organize your Rom Dat files."
9
+ readme = "README.md"
10
+ requires-python = ">=3.10"
11
+ license = {text = "MIT License"}
12
+ authors = [
13
+ {name = 'Lacides Miranda', email = 'laromicas@hotmail.com'},
14
+ ]
15
+ keywords = ["emulators", "roms"]
16
+ classifiers = [
17
+ 'Development Status :: 4 - Beta',
18
+ "Environment :: Console",
19
+ 'License :: OSI Approved :: MIT License',
20
+ "Operating System :: POSIX :: Linux",
21
+ 'Programming Language :: Python :: 3',
22
+ 'Topic :: System :: Emulators',
23
+ ]
24
+ dependencies = [
25
+ "datoso>=1.0.0",
26
+ ]
27
+ dynamic = ["version"]
28
+
29
+ [project.urls]
30
+ "Source Code" = "https://github.com/laromicas/datoso_seed_whdload"
31
+
32
+ [tool.setuptools]
33
+ packages = ["datoso_seed_whdload"]
34
+ license-files = ["LICENSE"]
35
+ include-package-data = true
36
+
37
+ [tool.setuptools.dynamic]
38
+ version = {attr = "datoso_seed_whdload.__version__"}
@@ -0,0 +1,17 @@
1
+ [metadata]
2
+ license_files =
3
+ LICENSE
4
+ CONTRIBUTORS.txt
5
+
6
+ [options]
7
+ package_dir =
8
+ =src
9
+ packages = find:
10
+
11
+ [options.packages.find]
12
+ where = src
13
+
14
+ [egg_info]
15
+ tag_build =
16
+ tag_date = 0
17
+
@@ -0,0 +1,6 @@
1
+ """Initialize seed variables."""
2
+ __all__ = ['__version__', '__author__', '__description__']
3
+ __version__ = '1.0.0'
4
+ __author__ = 'Lacides Miranda'
5
+ __description__ = 'WHDLoad is a collection of Amiga Roms'
6
+ __prefix__ = 'whdload'
@@ -0,0 +1,26 @@
1
+ """Actions for the whdload seed."""
2
+ from datoso_seed_whdload.dats import WhdloadDat
3
+
4
+ actions = {
5
+ '{dat_origin}': [
6
+ {
7
+ 'action': 'LoadDatFile',
8
+ '_class': WhdloadDat,
9
+ },
10
+ {
11
+ 'action': 'DeleteOld',
12
+ 'folder': '{dat_destination}',
13
+ },
14
+ {
15
+ 'action': 'Copy',
16
+ 'folder': '{dat_destination}',
17
+ },
18
+ {
19
+ 'action': 'SaveToDatabase',
20
+ },
21
+ ],
22
+ }
23
+
24
+ def get_actions() -> dict:
25
+ """Get the actions dictionary."""
26
+ return actions
@@ -0,0 +1,33 @@
1
+ """WhdloadDat class to parse different types of dat files."""
2
+
3
+ import re
4
+
5
+ from datoso.repositories.dat_file import ClrMameProDatFile
6
+
7
+
8
+ class WhdloadDat(ClrMameProDatFile):
9
+ """Whdload Dat class."""
10
+
11
+ seed: str = 'Whdload'
12
+
13
+ def initial_parse(self) -> list:
14
+ """Parse the dat file."""
15
+ # pylint: disable=R0801
16
+ system, suffix1, suffix2 = self.name.split(' - ')
17
+ self.prefix = 'Computer'
18
+ self.company, self.system = system.split(' ')
19
+ self.suffix = [suffix1, suffix2]
20
+ self.date = ''
21
+ return [self.prefix, self.company, self.system, self.suffix, self.get_date()]
22
+
23
+ def get_date(self) -> str:
24
+ """Get the date from the dat file."""
25
+ if self.date:
26
+ return self.date
27
+ if self.version:
28
+ result = re.findall(r'\(.*?\)', str(self.version))
29
+ self.date = result[len(result)-1][1:-1].replace('_CM','')
30
+ if self.file:
31
+ result = re.findall(r'\(.*?\)', str(self.file))
32
+ self.date = result[len(result)-1][1:-1].replace('_CM','')
33
+ return self.date
@@ -0,0 +1,97 @@
1
+ """Fetch and download DAT files."""
2
+ import os
3
+ import shutil
4
+ import urllib.request
5
+ import zipfile
6
+ from concurrent.futures import ThreadPoolExecutor
7
+ from datetime import datetime
8
+ from html.parser import HTMLParser
9
+ from pathlib import Path
10
+ from urllib.parse import urljoin
11
+
12
+ from dateutil import tz
13
+
14
+ from datoso.configuration.folder_helper import Folders
15
+ from datoso_seed_whdload import __prefix__
16
+
17
+ NAME = 'WHDLoad'
18
+ WHDLOAD_URL = 'http://armaxweb.free.fr/'
19
+
20
+ class MyHTMLParser(HTMLParser):
21
+ """HTML parser to get the DAT files."""
22
+
23
+ dats: list | None = None
24
+ rootpath = None
25
+
26
+ def handle_starttag(self, tag: str, attrs: list) -> None:
27
+ """Handle the start tag of an HTML element, capture the zip hrefs."""
28
+ if tag == 'a':
29
+ taga = dict(attrs)
30
+ if 'href' in taga:
31
+ href = taga['href']
32
+ if href.endswith('.zip') and href.startswith('dats/'):
33
+ self.dats.append(urljoin(self.rootpath, href).replace(' ', '%20'))
34
+
35
+
36
+ def download_dats(folder_helper: Folders) -> None:
37
+ """Download DAT files."""
38
+
39
+ def get_dat_links(name: str, url: str) -> list:
40
+ """Get the DAT links."""
41
+ print(f'Fetching {name} DAT files')
42
+ if not url.startswith(('http:', 'https:')):
43
+ msg = 'URL must start with "http:" or "https:"'
44
+ raise ValueError(msg)
45
+ red = urllib.request.urlopen(url) # noqa: S310
46
+ pleasurehtml = red.read()
47
+
48
+ parser = MyHTMLParser()
49
+ parser.dats = []
50
+ parser.rootpath = url
51
+ parser.folder_helper = folder_helper
52
+ parser.feed(str(pleasurehtml))
53
+ return parser.dats
54
+
55
+ def download_dat(href: str) -> None:
56
+ filename = Path(href).name.replace('%20', ' ')
57
+ if not href.startswith(('http:', 'https:')):
58
+ msg = 'URL must start with "http:" or "https:"'
59
+ raise ValueError(msg)
60
+ tmp_filename, _ = urllib.request.urlretrieve(href) # noqa: S310
61
+ local_filename = folder_helper.dats / filename
62
+ shutil.move(tmp_filename, local_filename)
63
+
64
+ links = get_dat_links(NAME, WHDLOAD_URL)
65
+
66
+ print(f'Downloading {NAME} DAT files')
67
+ with ThreadPoolExecutor(max_workers=10) as executor:
68
+ futures = [
69
+ executor.submit(download_dat, href) for href in links
70
+ ]
71
+ for future in futures:
72
+ future.result()
73
+
74
+ path = folder_helper.dats
75
+ files = os.listdir(folder_helper.dats)
76
+
77
+ for file_zip in files:
78
+ file = path / file_zip
79
+ with zipfile.ZipFile(file, 'r') as zip_ref:
80
+ zip_ref.extractall(path)
81
+ Path.unlink(file)
82
+
83
+ print('\nZipping files for backup')
84
+ backup_daily_name = f'whdload-{datetime.now(tz.tzlocal()).strftime("%Y-%m-%d")}.zip'
85
+ with zipfile.ZipFile(folder_helper.backup / backup_daily_name, 'w') as zip_ref:
86
+ for root, _, files in os.walk(folder_helper.dats):
87
+ for file in files:
88
+ zip_ref.write(Path(root) / file, arcname=Path(root).relative_to(folder_helper.dats) / file,
89
+ compress_type=zipfile.ZIP_DEFLATED, compresslevel=9)
90
+
91
+
92
+ def fetch() -> None:
93
+ """Fetch and download DAT files."""
94
+ folder_helper = Folders(seed=__prefix__)
95
+ folder_helper.clean_dats()
96
+ folder_helper.create_all()
97
+ download_dats(folder_helper)
@@ -0,0 +1,28 @@
1
+ """Rules for the Whdload seed."""
2
+ from datoso_seed_whdload.dats import WhdloadDat
3
+
4
+ rules = [
5
+ {
6
+ 'name': 'Whdload Dat',
7
+ '_class': WhdloadDat,
8
+ 'seed': 'Whdload',
9
+ 'priority': 0,
10
+ 'rules': [
11
+ {
12
+ 'key': 'url',
13
+ 'operator': 'contains',
14
+ 'value': 'www._whdload.org',
15
+ },
16
+ {
17
+ 'key': 'homepage',
18
+ 'operator': 'eq',
19
+ 'value': '_whdload',
20
+ },
21
+ ],
22
+ },
23
+ ]
24
+
25
+
26
+ def get_rules() -> list:
27
+ """Get the rules."""
28
+ return rules
@@ -0,0 +1,58 @@
1
+ Metadata-Version: 2.1
2
+ Name: datoso-seed-whdload
3
+ Version: 1.0.0
4
+ Summary: Python command line tool to download and organize your Rom Dat files.
5
+ Author-email: Lacides Miranda <laromicas@hotmail.com>
6
+ License: MIT License
7
+ Project-URL: Source Code, https://github.com/laromicas/datoso_seed_whdload
8
+ Keywords: emulators,roms
9
+ Classifier: Development Status :: 4 - Beta
10
+ Classifier: Environment :: Console
11
+ Classifier: License :: OSI Approved :: MIT License
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: System :: Emulators
15
+ Requires-Python: >=3.10
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+
19
+ ![Datoso](https://github.com/laromicas/datoso/blob/master/bearlogo.png)
20
+
21
+ # Datoso Seed Whdload
22
+
23
+ Datoso is a WIP Python command line tool to download and organize your Dat Roms.
24
+ As today the tool supports dat-omatic, redump, and translated-english dats.
25
+ It merges all the dats in a tree folder structure thought to use with Emulators rather than dats.
26
+ The dat file format must be compatible with [ROMVault](https://www.romvault.com/).
27
+
28
+ WHDLoad is a collection of Amiga Roms
29
+
30
+ ## Installation
31
+
32
+ Datoso requires python 3.10+.
33
+
34
+ Use pip (recommended to use a virtual environment):
35
+
36
+ ``` bash
37
+ # Install datoso base (doesn't do much without real plugins)
38
+ pip install datoso_seed_whdload
39
+
40
+ ```
41
+
42
+ ## Usage
43
+
44
+ Check [Datoso](https://github.com/laromicas/datoso) for usage.
45
+
46
+
47
+ ## TODO
48
+
49
+ - Tests
50
+
51
+ ## Contributing
52
+
53
+ Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
54
+ Please make sure to update tests as appropriate.
55
+
56
+ ## License
57
+
58
+ [MIT](https://choosealicense.com/licenses/mit/)
@@ -0,0 +1,14 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ setup.cfg
5
+ src/datoso_seed_whdload/__init__.py
6
+ src/datoso_seed_whdload/actions.py
7
+ src/datoso_seed_whdload/dats.py
8
+ src/datoso_seed_whdload/fetch.py
9
+ src/datoso_seed_whdload/rules.py
10
+ src/datoso_seed_whdload.egg-info/PKG-INFO
11
+ src/datoso_seed_whdload.egg-info/SOURCES.txt
12
+ src/datoso_seed_whdload.egg-info/dependency_links.txt
13
+ src/datoso_seed_whdload.egg-info/requires.txt
14
+ src/datoso_seed_whdload.egg-info/top_level.txt
@@ -0,0 +1 @@
1
+ datoso_seed_whdload