generalizing-machine 0.0.1__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.
- generalizing_machine-0.0.1/LICENSE +21 -0
- generalizing_machine-0.0.1/MANIFEST.in +1 -0
- generalizing_machine-0.0.1/PKG-INFO +35 -0
- generalizing_machine-0.0.1/README.md +14 -0
- generalizing_machine-0.0.1/pyproject.toml +34 -0
- generalizing_machine-0.0.1/setup.cfg +4 -0
- generalizing_machine-0.0.1/src/generalizing_machine/__init__.py +36 -0
- generalizing_machine-0.0.1/src/generalizing_machine/cli.py +18 -0
- generalizing_machine-0.0.1/src/generalizing_machine/githf.py +97 -0
- generalizing_machine-0.0.1/src/generalizing_machine/machine.py +16 -0
- generalizing_machine-0.0.1/src/generalizing_machine.egg-info/PKG-INFO +35 -0
- generalizing_machine-0.0.1/src/generalizing_machine.egg-info/SOURCES.txt +14 -0
- generalizing_machine-0.0.1/src/generalizing_machine.egg-info/dependency_links.txt +1 -0
- generalizing_machine-0.0.1/src/generalizing_machine.egg-info/entry_points.txt +2 -0
- generalizing_machine-0.0.1/src/generalizing_machine.egg-info/requires.txt +5 -0
- generalizing_machine-0.0.1/src/generalizing_machine.egg-info/top_level.txt +1 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Alexander Fedotov
|
|
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 @@
|
|
|
1
|
+
include src/machine_name/*.yaml
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: generalizing-machine
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Machine that generalizes.
|
|
5
|
+
Author-email: Alexander Fedotov <alex.fedotov@aol.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/generalizing-machine/generalizing-machine
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/generalizing-machine/generalizing-machine/issues
|
|
8
|
+
Keywords: generalizing-machine
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: PyGithub>=2.6.0
|
|
16
|
+
Requires-Dist: PyYAML>=6.0.1
|
|
17
|
+
Requires-Dist: urllib3>=2.0.4
|
|
18
|
+
Requires-Dist: requests>=2.32.3
|
|
19
|
+
Requires-Dist: click>=8.3.0
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# Generalizing Machine
|
|
23
|
+
A Machine that generalizes.
|
|
24
|
+
<pre>
|
|
25
|
+
pip install generalizing-machine
|
|
26
|
+
</pre>
|
|
27
|
+
Then:
|
|
28
|
+
```Python
|
|
29
|
+
# Python
|
|
30
|
+
import machine_name
|
|
31
|
+
```
|
|
32
|
+
Or:
|
|
33
|
+
<pre>
|
|
34
|
+
uvx generalizing-machine [ARGUMENT] [OPTION]
|
|
35
|
+
</pre>
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=67.0"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
[project]
|
|
5
|
+
name = "generalizing-machine"
|
|
6
|
+
version = "0.0.1"
|
|
7
|
+
authors = [
|
|
8
|
+
{name="Alexander Fedotov", email="alex.fedotov@aol.com"},
|
|
9
|
+
]
|
|
10
|
+
description = "A Machine that generalizes."
|
|
11
|
+
readme = "README.md"
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
classifiers=[
|
|
14
|
+
"Programming Language :: Python :: 3",
|
|
15
|
+
"License :: OSI Approved :: MIT License",
|
|
16
|
+
"Operating System :: OS Independent",
|
|
17
|
+
]
|
|
18
|
+
|
|
19
|
+
keywords = ["generalizing-machine"]
|
|
20
|
+
|
|
21
|
+
dependencies = [
|
|
22
|
+
"PyGithub >= 2.6.0",
|
|
23
|
+
"PyYAML >= 6.0.1",
|
|
24
|
+
"urllib3 >= 2.0.4",
|
|
25
|
+
"requests >= 2.32.3",
|
|
26
|
+
"click >= 8.3.0"
|
|
27
|
+
]
|
|
28
|
+
|
|
29
|
+
[project.scripts]
|
|
30
|
+
generalizing-machine = "generalizing_machine.cli:run"
|
|
31
|
+
|
|
32
|
+
[project.urls]
|
|
33
|
+
"Homepage" = "https://github.com/generalizing-machine/generalizing-machine"
|
|
34
|
+
"Bug Tracker" = "https://github.com/generalizing-machine/generalizing-machine/issues"
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Python
|
|
3
|
+
|
|
4
|
+
"""Copyright (c) Alexander Fedotov.
|
|
5
|
+
This source code is licensed under the license found in the
|
|
6
|
+
LICENSE file in the root directory of this source tree.
|
|
7
|
+
"""
|
|
8
|
+
import os
|
|
9
|
+
from . import githf
|
|
10
|
+
import yaml
|
|
11
|
+
|
|
12
|
+
# Constants
|
|
13
|
+
MACHINE_ORGANIZATION_NAME = 'generalizing-machine' # or other organization
|
|
14
|
+
PRIVATE_REPO_WITH_TEXT = 'generalizing_machine'
|
|
15
|
+
|
|
16
|
+
# Location of the file that is running
|
|
17
|
+
WHERE_ARE_WE = os.path.dirname(__file__)
|
|
18
|
+
|
|
19
|
+
try:
|
|
20
|
+
gh = githf.connectto_repo(organization=MACHINE_ORGANIZATION_NAME,
|
|
21
|
+
repository_name=PRIVATE_REPO_WITH_TEXT,
|
|
22
|
+
private=True)
|
|
23
|
+
MACHINE_YAML = githf.read_file(repository=gh, file_path='machina.yaml')
|
|
24
|
+
|
|
25
|
+
except Exception as e:
|
|
26
|
+
machina_path = os.path.join(WHERE_ARE_WE, 'machina.yaml')
|
|
27
|
+
with open(machina_path, 'r') as yaml_file:
|
|
28
|
+
MACHINE_YAML = yaml_file.read()
|
|
29
|
+
|
|
30
|
+
NAME_OF_THE_MACHINE = yaml.load(MACHINE_YAML, Loader=yaml.FullLoader)
|
|
31
|
+
|
|
32
|
+
# Save the file
|
|
33
|
+
# file_path = os.path.join(where_are_we, 'other.yaml')
|
|
34
|
+
# with open(file_path, 'w') as yaml_file:
|
|
35
|
+
# yaml.dump(MACHINE_YAML, yaml_file)
|
|
36
|
+
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Python
|
|
3
|
+
|
|
4
|
+
"""Copyright (c) Alexander Fedotov.
|
|
5
|
+
This source code is licensed under the license found in the
|
|
6
|
+
LICENSE file in the root directory of this source tree.
|
|
7
|
+
"""
|
|
8
|
+
from .machine import machine
|
|
9
|
+
import click
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
@click.command()
|
|
13
|
+
# @click.option('--count', default=1, help='number of attempts')
|
|
14
|
+
# and use it in the commend as --count=1
|
|
15
|
+
# @click.argument('arg')
|
|
16
|
+
def run(): #arg): # (count, arg): if with option.
|
|
17
|
+
click.echo('Running package-name') # with') + arg)
|
|
18
|
+
machine() #arg)
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Python
|
|
3
|
+
|
|
4
|
+
"""Copyright (c) Alexander Fedotov.
|
|
5
|
+
This source code is licensed under the license found in the
|
|
6
|
+
LICENSE file in the root directory of this source tree.
|
|
7
|
+
"""
|
|
8
|
+
from os import environ
|
|
9
|
+
from github import Github, UnknownObjectException
|
|
10
|
+
from urllib3 import disable_warnings
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
github_token = environ.get('GITHUB_TOKEN', '')
|
|
14
|
+
github_name = environ.get('GITHUB_NAME', '')
|
|
15
|
+
github_email = environ.get('GITHUB_EMAIL', '')
|
|
16
|
+
|
|
17
|
+
# The useless urllib3 warning is too maddening for an ordinary human being.
|
|
18
|
+
disable_warnings()
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# Repo
|
|
22
|
+
def connectto_repo(organization=None,
|
|
23
|
+
repository_name=None,
|
|
24
|
+
private=False):
|
|
25
|
+
"""
|
|
26
|
+
Establish a connection with a GitHub repository.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
organization (str, optional): The name of the organization. If not provided,
|
|
30
|
+
the repository is assumed to be owned by the authenticated user.
|
|
31
|
+
repository_name (str): The name of the repository.
|
|
32
|
+
private (bool, optional): Whether the repository is private. Defaults to False.
|
|
33
|
+
|
|
34
|
+
Returns:
|
|
35
|
+
github.Repository.Repository: The GitHub repository object if the connection is successful.
|
|
36
|
+
None: If the connection fails.
|
|
37
|
+
|
|
38
|
+
Raises:
|
|
39
|
+
github.UnknownObjectException: If the repository does not exist.
|
|
40
|
+
|
|
41
|
+
Note:
|
|
42
|
+
The function requires the following environment variables to be set:
|
|
43
|
+
- GITHUB_TOKEN: The personal access token for authentication.
|
|
44
|
+
- GITHUB_NAME: The name of the authenticated user.
|
|
45
|
+
- GITHUB_EMAIL: The email of the authenticated user.
|
|
46
|
+
|
|
47
|
+
"""
|
|
48
|
+
|
|
49
|
+
gh = Github(github_token, verify=False)
|
|
50
|
+
if organization:
|
|
51
|
+
org = gh.get_organization(organization)
|
|
52
|
+
try:
|
|
53
|
+
repo = org.get_repo(f'{repository_name}')
|
|
54
|
+
except UnknownObjectException:
|
|
55
|
+
# print('Can not connect YOU to this repo in this organization')
|
|
56
|
+
repo = None
|
|
57
|
+
return repo
|
|
58
|
+
else:
|
|
59
|
+
user = gh.get_user()
|
|
60
|
+
try:
|
|
61
|
+
repo = user.get_repo(repository_name)
|
|
62
|
+
except UnknownObjectException:
|
|
63
|
+
# print('Can not connect YOU to this repo')
|
|
64
|
+
repo = None
|
|
65
|
+
return repo
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
def read_file(repository,
|
|
69
|
+
file_path):
|
|
70
|
+
"""
|
|
71
|
+
Read the contents of a file in a GitHub repository.
|
|
72
|
+
|
|
73
|
+
Args:
|
|
74
|
+
repository (github.Repository.Repository): The GitHub repository object.
|
|
75
|
+
file_path (str): The path to the file in the repository, formatted as
|
|
76
|
+
'directory_in_repo/subdirectory/file.ext'.
|
|
77
|
+
|
|
78
|
+
Returns:
|
|
79
|
+
str: The contents of the file as a string. If the file does not exist, an empty string is returned.
|
|
80
|
+
|
|
81
|
+
Raises:
|
|
82
|
+
github.UnknownObjectException: If the file does not exist in the repository.
|
|
83
|
+
|
|
84
|
+
Note:
|
|
85
|
+
This function assumes that the repository object has already been authenticated and connected.
|
|
86
|
+
"""
|
|
87
|
+
try:
|
|
88
|
+
# Get the file if it exists
|
|
89
|
+
ingested_file = repository.get_contents(file_path)
|
|
90
|
+
content = ingested_file.decoded_content.decode("utf-8")
|
|
91
|
+
|
|
92
|
+
except UnknownObjectException:
|
|
93
|
+
# The file doesn't exist
|
|
94
|
+
# print('The file does not exist')
|
|
95
|
+
content = ''
|
|
96
|
+
|
|
97
|
+
return content
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# -*- coding: utf-8 -*-
|
|
2
|
+
# Python
|
|
3
|
+
|
|
4
|
+
"""Copyright (c) Alexander Fedotov.
|
|
5
|
+
This source code is licensed under the license found in the
|
|
6
|
+
LICENSE file in the root directory of this source tree.
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
def machine(): # arg=None):
|
|
11
|
+
print(' main.')
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
if __name__ == '__main__':
|
|
15
|
+
machine()
|
|
16
|
+
...
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: generalizing-machine
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Machine that generalizes.
|
|
5
|
+
Author-email: Alexander Fedotov <alex.fedotov@aol.com>
|
|
6
|
+
Project-URL: Homepage, https://github.com/generalizing-machine/generalizing-machine
|
|
7
|
+
Project-URL: Bug Tracker, https://github.com/generalizing-machine/generalizing-machine/issues
|
|
8
|
+
Keywords: generalizing-machine
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
11
|
+
Classifier: Operating System :: OS Independent
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Description-Content-Type: text/markdown
|
|
14
|
+
License-File: LICENSE
|
|
15
|
+
Requires-Dist: PyGithub>=2.6.0
|
|
16
|
+
Requires-Dist: PyYAML>=6.0.1
|
|
17
|
+
Requires-Dist: urllib3>=2.0.4
|
|
18
|
+
Requires-Dist: requests>=2.32.3
|
|
19
|
+
Requires-Dist: click>=8.3.0
|
|
20
|
+
Dynamic: license-file
|
|
21
|
+
|
|
22
|
+
# Generalizing Machine
|
|
23
|
+
A Machine that generalizes.
|
|
24
|
+
<pre>
|
|
25
|
+
pip install generalizing-machine
|
|
26
|
+
</pre>
|
|
27
|
+
Then:
|
|
28
|
+
```Python
|
|
29
|
+
# Python
|
|
30
|
+
import machine_name
|
|
31
|
+
```
|
|
32
|
+
Or:
|
|
33
|
+
<pre>
|
|
34
|
+
uvx generalizing-machine [ARGUMENT] [OPTION]
|
|
35
|
+
</pre>
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
MANIFEST.in
|
|
3
|
+
README.md
|
|
4
|
+
pyproject.toml
|
|
5
|
+
src/generalizing_machine/__init__.py
|
|
6
|
+
src/generalizing_machine/cli.py
|
|
7
|
+
src/generalizing_machine/githf.py
|
|
8
|
+
src/generalizing_machine/machine.py
|
|
9
|
+
src/generalizing_machine.egg-info/PKG-INFO
|
|
10
|
+
src/generalizing_machine.egg-info/SOURCES.txt
|
|
11
|
+
src/generalizing_machine.egg-info/dependency_links.txt
|
|
12
|
+
src/generalizing_machine.egg-info/entry_points.txt
|
|
13
|
+
src/generalizing_machine.egg-info/requires.txt
|
|
14
|
+
src/generalizing_machine.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
generalizing_machine
|