crieur 1.3.1__tar.gz → 1.3.2__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.

Potentially problematic release.


This version of crieur might be problematic. Click here for more details.

@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: crieur
3
- Version: 1.3.1
3
+ Version: 1.3.2
4
4
  Summary: A Static Revue Generator.
5
5
  Project-URL: Homepage, https://gitlab.huma-num.fr/ecrinum/crieur
6
6
  Project-URL: Issues, https://gitlab.huma-num.fr/ecrinum/crieur/-/issues
@@ -1,4 +1,4 @@
1
1
  from pathlib import Path
2
2
 
3
- VERSION = "1.3.1"
3
+ VERSION = "1.3.2"
4
4
  ROOT_DIR = Path(__file__).parent
@@ -101,14 +101,27 @@ def stylo(
101
101
  with httpx.stream("GET", url, timeout=None) as r:
102
102
  for data in r.iter_bytes():
103
103
  fd.write(data)
104
+ else:
105
+ print(
106
+ f"Source already exists: `{zip_path}` (no download). "
107
+ "Use the `--force` option to download it again"
108
+ )
104
109
 
105
110
  target_path = sources_path / f"{i + 1}-{stylo_id}"
106
111
  try:
107
112
  with zipfile.ZipFile(zip_path, "r") as zip_ref:
108
113
  zip_ref.extractall(target_path)
109
- print(f"Data downloaded and extracted to {target_path}")
114
+ print(f"Data extracted to {target_path}")
110
115
  except zipfile.BadZipFile:
116
+ zip_problematic_path = Path() / f"problematic-export-{i + 1}-{stylo_id}.zip"
117
+ zip_path.rename(zip_problematic_path)
111
118
  print(f"Unable to find corpus with id {stylo_id}!")
119
+ print(
120
+ f"Check out the content of {zip_problematic_path} to try to understand."
121
+ )
122
+ print(
123
+ "Either you use a wrong corpus id or there is an issue with the export."
124
+ )
112
125
  return
113
126
 
114
127
 
@@ -2,6 +2,7 @@ from dataclasses import dataclass
2
2
  from typing import Optional
3
3
 
4
4
  from dataclass_wizard import DatePattern, DumpMeta, YAMLWizard
5
+ from dataclass_wizard import errors as dw_errors
5
6
  from slugify import slugify
6
7
  from yaml.composer import ComposerError
7
8
 
@@ -29,11 +30,16 @@ class Numero(YAMLWizard):
29
30
  )
30
31
  article_yaml_path = article_folder / f"{article_slug}.yaml"
31
32
  try:
32
- loaded_article = Article.from_yaml_file(article_yaml_path)
33
- except ComposerError:
34
- loaded_article = Article.from_yaml(
35
- article_yaml_path.read_text().split("---")[1]
36
- )
33
+ try:
34
+ loaded_article = Article.from_yaml_file(article_yaml_path)
35
+ except ComposerError:
36
+ loaded_article = Article.from_yaml(
37
+ article_yaml_path.read_text().split("---")[1]
38
+ )
39
+ except dw_errors.ParseError as e:
40
+ print(f"Metadata error in `{article['article']['title']}`:")
41
+ print(e)
42
+ exit(1)
37
43
  if not loaded_article.id:
38
44
  loaded_article.id = article_slug
39
45
  loaded_article.content_md = (
@@ -46,7 +52,7 @@ class Numero(YAMLWizard):
46
52
  )
47
53
  loaded_article.numero = self
48
54
  loaded_articles.append(loaded_article)
49
- self.articles = loaded_articles
55
+ self.articles = sorted(loaded_articles, reverse=True)
50
56
 
51
57
 
52
58
  @dataclass
@@ -65,6 +71,14 @@ class Article(YAMLWizard):
65
71
  def __post_init__(self):
66
72
  self.slug = slugify(self.title)
67
73
 
74
+ def __eq__(self, other):
75
+ return self.id == other.id
76
+
77
+ def __lt__(self, other: "Article"):
78
+ if not isinstance(other, Article):
79
+ return NotImplemented
80
+ return self.date < other.date
81
+
68
82
 
69
83
  def configure_numero(yaml_path):
70
84
  # Preserves abstract_fr key (vs. abstract-fr) when converting to_yaml()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes