pygitpub 0.0.61__tar.gz → 0.0.62__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.5
2
2
  Name: pygitpub
3
- Version: 0.0.61
3
+ Version: 0.0.62
4
4
  Summary: Pygitpub will help you work with github
5
5
  Project-URL: Homepage, https://github.com/veltzer/pygitpub
6
6
  Project-URL: Bug Tracker, https://github.com/veltzer/pygitpub/issues
@@ -41,7 +41,7 @@ project website: https://veltzer.github.io/pygitpub
41
41
 
42
42
  author: Mark Veltzer
43
43
 
44
- version: 0.0.61
44
+ version: 0.0.62
45
45
 
46
46
  ![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)
47
47
 
@@ -9,7 +9,7 @@ project website: https://veltzer.github.io/pygitpub
9
9
 
10
10
  author: Mark Veltzer
11
11
 
12
- version: 0.0.61
12
+ version: 0.0.62
13
13
 
14
14
  ![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)
15
15
 
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "pygitpub"
7
- version = "0.0.61"
7
+ version = "0.0.62"
8
8
  requires-python = ">=3.14"
9
9
  authors = [
10
10
  { name = "Mark Veltzer", email = "mark.veltzer@gmail.com" }
@@ -17,7 +17,7 @@ from pytconf.registry import the_registry
17
17
  import pygitpub.static
18
18
  from pygitpub.configs import AFFILIATIONS, ConfigAlgo, ConfigGithub, ConfigOutput
19
19
  from pygitpub.utils.lua import config_path, load_lua_file
20
- from pygitpub.utils.misc import delete, get_all_git_repos
20
+ from pygitpub.utils.misc import get_all_git_repos
21
21
 
22
22
 
23
23
  def get_base_dir() -> str:
@@ -77,21 +77,15 @@ def yield_repos():
77
77
  ],
78
78
  )
79
79
  def fix_metadata() -> None:
80
- orig_folder = os.getcwd()
81
80
  for repo in yield_repos():
82
81
  folder = get_repo_folder(repo)
83
82
  if not os.path.isdir(folder):
84
- # print(f"folder [{folder}] does not exist, continuing...")
85
83
  continue
86
- os.chdir(folder)
87
- # print(f"doing [{folder}]...")
88
- file_path = config_path("project")
84
+ file_path = os.path.join(folder, config_path("project"))
89
85
  if not os.path.isfile(file_path):
90
- os.chdir(orig_folder)
91
86
  continue
92
87
  project = load_lua_file(file_path)
93
88
  if "DESCRIPTION_SHORT" not in project:
94
- os.chdir(orig_folder)
95
89
  continue
96
90
  description_short = project["DESCRIPTION_SHORT"]
97
91
  if description_short != repo.description:
@@ -101,7 +95,6 @@ def fix_metadata() -> None:
101
95
  repo.edit(description=description_short)
102
96
  if "KEYWORDS" not in project:
103
97
  print(f"{folder} no keywords")
104
- os.chdir(orig_folder)
105
98
  continue
106
99
  keywords = project["KEYWORDS"]
107
100
  if set(keywords) != set(repo.get_topics()):
@@ -109,7 +102,6 @@ def fix_metadata() -> None:
109
102
  print(f"keywords is [{keywords}]")
110
103
  print(f"repo.get_topics() is [{repo.get_topics()}]")
111
104
  repo.replace_topics(keywords)
112
- os.chdir(orig_folder)
113
105
 
114
106
 
115
107
  @register_endpoint(
@@ -148,8 +140,8 @@ def homepage_fix() -> None:
148
140
  )
149
141
  def repos_json() -> None:
150
142
  for repo in yield_repos():
151
- # pylint: disable=protected-access
152
- json.dump(repo._rawData, fp=sys.stdout, indent=4)
143
+ json.dump(repo.raw_data, fp=sys.stdout, indent=4)
144
+ print()
153
145
 
154
146
 
155
147
  @register_endpoint(
@@ -189,6 +181,7 @@ def repos_list() -> None:
189
181
  for repo in yield_repos():
190
182
  if ConfigOutput.verbose:
191
183
  json.dump(obj=repo.raw_data, fp=sys.stdout, indent=4, sort_keys=True)
184
+ print()
192
185
  else:
193
186
  print(f"{repo.name}")
194
187
 
@@ -202,7 +195,7 @@ def repos_list() -> None:
202
195
  ],
203
196
  )
204
197
  def cleanup() -> None:
205
- # pylint: disable=too-many-branches
198
+ # pylint: disable=too-many-branches,too-many-statements
206
199
  for repo in yield_repos():
207
200
  # 1. Cleanup workflow runs
208
201
  for workflow in repo.get_workflows():
@@ -226,7 +219,10 @@ def cleanup() -> None:
226
219
  delete_it = True
227
220
  if delete_it:
228
221
  print(f"deleting {repo.name} {workflow.name} {run.head_branch} {run.conclusion} {run.url}")
229
- delete(run)
222
+ try:
223
+ run.delete()
224
+ except github.GithubException as e:
225
+ print(f"Failed to delete run: {e}")
230
226
  else:
231
227
  existing += 1
232
228
 
@@ -310,12 +306,8 @@ def runs_show_running() -> None:
310
306
  def runs_show_failing() -> None:
311
307
  for repo in yield_repos():
312
308
  for workflow in repo.get_workflows():
313
- for run in workflow.get_runs():
314
- last_run = run
315
- break
316
- else:
317
- continue
318
- if last_run.conclusion == "failure":
309
+ last_run = next(iter(workflow.get_runs()), None)
310
+ if last_run is not None and last_run.conclusion == "failure":
319
311
  print(f"{repo.name}: {workflow.name} {last_run.conclusion}")
320
312
 
321
313
 
@@ -329,12 +321,8 @@ def runs_show_failing() -> None:
329
321
  def runs_show_not_success() -> None:
330
322
  for repo in yield_repos():
331
323
  for workflow in repo.get_workflows():
332
- for run in workflow.get_runs():
333
- last_run = run
334
- break
335
- else:
336
- continue
337
- if last_run.conclusion != "success":
324
+ last_run = next(iter(workflow.get_runs()), None)
325
+ if last_run is not None and last_run.conclusion != "success":
338
326
  print(f"{repo.name}: {workflow.name} {last_run.conclusion}")
339
327
 
340
328
 
@@ -346,7 +334,6 @@ def runs_show_not_success() -> None:
346
334
  ],
347
335
  )
348
336
  def pull_all() -> None:
349
- orig_folder = os.getcwd()
350
337
  base_dir = get_base_dir()
351
338
  for repo in yield_repos():
352
339
  project = repo.name
@@ -354,15 +341,14 @@ def pull_all() -> None:
354
341
  if os.path.isdir(folder):
355
342
  if not os.path.isfile(os.path.join(folder, ".skip")):
356
343
  print(f"project [{project}] exists, pulling it...")
357
- os.chdir(folder)
358
344
  subprocess.check_call(
359
345
  [
360
346
  "git",
361
347
  "pull",
362
348
  # "--tags",
363
- ]
349
+ ],
350
+ cwd=folder,
364
351
  )
365
- os.chdir(orig_folder)
366
352
  else:
367
353
  print(f"project [{project}] exists, skipping it because of .skip file...")
368
354
  else:
@@ -1,5 +1,5 @@
1
1
  """ version which can be consumed from within the module """
2
- VERSION_STR = "0.0.61"
2
+ VERSION_STR = "0.0.62"
3
3
  DESCRIPTION = "Pygitpub will help you work with github"
4
4
  APP_NAME = "pygitpub"
5
5
  LOGGER_NAME = "pygitpub"
@@ -19,13 +19,6 @@ def get_number_of_files(folder: str) -> int:
19
19
  return count
20
20
 
21
21
 
22
- def delete(workflow_run):
23
- # stolen from
24
- # https://github.com/PyGithub/PyGithub/blob/master/github/WorkflowRun.py
25
- # which is not yet in released
26
- # pylint: disable=protected-access
27
- status, _, _ = workflow_run._requester.requestJson("DELETE", workflow_run.url)
28
- return status == 204
29
22
 
30
23
 
31
24
  def get_all_git_repos(base_dir: str) -> set[str]:
File without changes
File without changes