gismap 0.1.0__py3-none-any.whl → 0.2.0__py3-none-any.whl

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.
gismap/utils/requests.py CHANGED
@@ -1,12 +1,19 @@
1
1
  from time import sleep
2
2
  import requests
3
+ from importlib.metadata import metadata
3
4
  from gismap.utils.logger import logger
4
5
 
5
6
 
7
+ infos = metadata("gismap")
6
8
  session = requests.Session()
9
+ session.headers.update(
10
+ {
11
+ "User-Agent": f"{infos['name']}/{infos['Version']} ({'; '.join(infos.get_all('Project-URL'))}; Contact, {infos['author-email']}"
12
+ }
13
+ )
7
14
 
8
15
 
9
- def get(url, params=None):
16
+ def get(url, params=None, n_trials=10):
10
17
  """
11
18
  Parameters
12
19
  ----------
@@ -20,14 +27,20 @@ def get(url, params=None):
20
27
  :class:`str`
21
28
  Result.
22
29
  """
23
- while True:
24
- r = session.get(url, params=params)
25
- if r.status_code == 429:
26
- try:
27
- t = int(r.headers["Retry-After"])
28
- except KeyError:
29
- t = 60
30
- logger.warning(f"Too many requests. Auto-retry in {t} seconds.")
30
+ for attempt in range(n_trials):
31
+ try:
32
+ r = session.get(url, params=params)
33
+ if r.status_code == 429:
34
+ try:
35
+ t = int(r.headers["Retry-After"])
36
+ except KeyError:
37
+ t = 60
38
+ logger.warning(f"Too many requests. Auto-retry in {t} seconds.")
39
+ sleep(t)
40
+ else:
41
+ return r.text
42
+ except requests.exceptions.ConnectionError:
43
+ t = 6
44
+ logger.warning(f"Connection error. Auto-retry in {t} seconds.")
31
45
  sleep(t)
32
- else:
33
- return r.text
46
+ raise requests.exceptions.ConnectionError(f"Unable to retrieve {url}")
gismap/utils/text.py CHANGED
@@ -1,4 +1,5 @@
1
1
  from bof.fuzz import Process
2
+ import unicodedata
2
3
 
3
4
 
4
5
  class Corrector:
@@ -90,4 +91,68 @@ def clean_aliases(name, alias_list):
90
91
  :class:`list`
91
92
  Aliases deduped, sorted, and with main name removed.
92
93
  """
93
- return sorted(set(n for n in alias_list if n != name))
94
+ return sorted(set(n for nn in alias_list for n in [nn, asciify(nn)] if n != name))
95
+
96
+
97
+ def asciify(text):
98
+ """
99
+ Parameters
100
+ ----------
101
+ text::class:`str`
102
+ Some text (typically names) with annoying accents.
103
+
104
+ Returns
105
+ -------
106
+ :class:`str`
107
+ Same text simplified into ascii.
108
+
109
+ Examples
110
+ --------
111
+ >>> asciify('Ana Bušić')
112
+ 'Ana Busic'
113
+ >>> asciify("Thomas Deiß")
114
+ 'Thomas Deiss'
115
+ """
116
+ text = text.replace("ß", "ss")
117
+ decomposed = unicodedata.normalize("NFD", text)
118
+ no_accents = "".join(c for c in decomposed if unicodedata.category(c) != "Mn")
119
+ ascii_text = no_accents.encode("ascii", "ignore").decode()
120
+ return ascii_text
121
+
122
+
123
+ def normalized_name(txt):
124
+ """
125
+ Try to normalize names for facilitating comparisons. Name is lowered, split, asciified, sorted, and filtered.
126
+
127
+ Parameters
128
+ ----------
129
+ txt: :class:`str`
130
+
131
+ Returns
132
+ -------
133
+ :class:`str`
134
+
135
+ Examples
136
+ --------
137
+
138
+ >>> normalized_name("Thomas Deiß")
139
+ 'deiss thomas'
140
+ >>> normalized_name("Dario Rossi 001")
141
+ 'dario rossi'
142
+ >>> normalized_name("James W. Roberts")
143
+ 'james roberts'
144
+ """
145
+ return " ".join(
146
+ sorted(
147
+ asciify(a)
148
+ for a in txt.lower().replace("-", " ").split()
149
+ if not (a.isdigit() or (len(a) < 3 and "." in a))
150
+ )
151
+ )
152
+
153
+
154
+ def auto_int(txt):
155
+ try:
156
+ return int(txt)
157
+ except ValueError:
158
+ return txt
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gismap
3
- Version: 0.1.0
3
+ Version: 0.2.0
4
4
  Summary: GISMAP leverages DBLP and HAL databases to provide cartography tools for you and your lab.
5
5
  Project-URL: Repository, https://github.com/balouf/gismap
6
6
  Project-URL: Documentation, https://balouf.github.io/gismap
@@ -11,6 +11,8 @@ License-File: AUTHORS.md
11
11
  Requires-Python: >=3.10
12
12
  Requires-Dist: bof>=0.3.5
13
13
  Requires-Dist: gismo>=0.5.2
14
+ Requires-Dist: ipykernel>=6.30.1
15
+ Requires-Dist: tqdm>=4.67.1
14
16
  Description-Content-Type: text/markdown
15
17
 
16
18
  # Generic Information Search: Mapping and Analysis of Publications
@@ -0,0 +1,29 @@
1
+ gismap/__init__.py,sha256=wZhnsqnlouh2Ugsb4L36K9QG8IEGrvI7s9biEv6LjRw,735
2
+ gismap/author.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
+ gismap/gismap.py,sha256=h0hwdogXGFqerm-5ZPeT-irPn91pCcQRjiHThXsRzEk,19
4
+ gismap/gismo.py,sha256=kBzvlo-fqcvEgwQt-c_hHkfI1oTjBbKKb54vM8il_nI,6295
5
+ gismap/search.py,sha256=nsUoDsFGeEtvCZ0dB7ooRPC_6qsazkiWx_oM7dHdNV4,4932
6
+ gismap/lab/__init__.py,sha256=WeJkoNZmFnLoEgK_nwXqZrA4nQtpeTLPf6PPMFIGb4k,415
7
+ gismap/lab/egomap.py,sha256=L5OKeZR7RCfX3EPm859-jZ1jnqlC3kpa0jybofhLPPc,1328
8
+ gismap/lab/expansion.py,sha256=fYcUvkGi3W1GTx2gnFT1z3cI-jlZFFAicDM99wi2wzE,6186
9
+ gismap/lab/filters.py,sha256=LL3jeCqLBpLeaz1lz5IvduV4G1xBPaty9SHiBxoYgak,486
10
+ gismap/lab/graph.py,sha256=UTmuJsUXC9ntmAWoH46cBW3CTIGKus5z1G045yBLzAQ,6673
11
+ gismap/lab/lab.py,sha256=Uc9Qg7Okf3L5K8gHTlnOv7lPbeA9OBfivCmZwRPwzp8,5331
12
+ gismap/lab/lab_author.py,sha256=jQhq1spZP5P-Bpzr5E_OP73gWy3SG6UjiVCGotjm57s,2439
13
+ gismap/lab/lip6.py,sha256=LLLjV8zNqwdkvtuV4nfmScCDlaeeGw79I0KQuOQ1_Yo,1443
14
+ gismap/lab/toulouse.py,sha256=Ex3lBPdYhAzAnPQw9Driho7joJNTHLpE_nNMooQH_nc,1495
15
+ gismap/lab/vis.py,sha256=j92WFmYZ0Szg10tq332PT5jQn3YbJSIOkYraVcmxiNk,8293
16
+ gismap/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
17
+ gismap/sources/dblp.py,sha256=_AgPgDbHYYaeJVam43eExv1VsglvAV46eP77RL7o9Fo,5278
18
+ gismap/sources/hal.py,sha256=3VjiUH5amNfJYV5uAtX-JcGWMNKUkmjfXU0Osca9CC8,10021
19
+ gismap/sources/models.py,sha256=yJPBXcJO6MgOrSXgpGPepHDDtniJP1OsK8OSz__VzYc,543
20
+ gismap/sources/multi.py,sha256=HQMQ4kcDwg0rZ42av98DZ17o83dpR2fD4KtP1yFX14c,4352
21
+ gismap/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
22
+ gismap/utils/common.py,sha256=nx1f60yNwFpl1oz08h-R5o0xK9CbJv9tmYLDk61dwYA,2898
23
+ gismap/utils/logger.py,sha256=1YALIaNYKTqeIyyCnYxzvZTK7x4FTSfYYl5CP9IMw8E,86
24
+ gismap/utils/requests.py,sha256=DA-ifVMdcOtipDSqYdVRQi-7CGR5WCTYiGyZ7Xu78q0,1291
25
+ gismap/utils/text.py,sha256=1_9DlduAYh7Nz-yAg-MaCTmdKbPPmuIY20bb87t7JAQ,3810
26
+ gismap-0.2.0.dist-info/METADATA,sha256=XvYw05O-XgvC_5Ormcwjt4FOkbaJHHn-1pvwkV_ma8Q,2560
27
+ gismap-0.2.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
28
+ gismap-0.2.0.dist-info/licenses/AUTHORS.md,sha256=oDR4mptVUBMq0WKIpt19Km1Bdfz3cO2NAOVgwVfTO8g,131
29
+ gismap-0.2.0.dist-info/RECORD,,
@@ -1,25 +0,0 @@
1
- gismap/__init__.py,sha256=TFBKB5AwAxzmcpIB48EpT4Ud9S417i5Obh85w2t1-Zc,598
2
- gismap/author.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
- gismap/gismap.py,sha256=h0hwdogXGFqerm-5ZPeT-irPn91pCcQRjiHThXsRzEk,19
4
- gismap/gismo.py,sha256=kBzvlo-fqcvEgwQt-c_hHkfI1oTjBbKKb54vM8il_nI,6295
5
- gismap/search.py,sha256=nsUoDsFGeEtvCZ0dB7ooRPC_6qsazkiWx_oM7dHdNV4,4932
6
- gismap/lab/__init__.py,sha256=UQVY6Sk7o9O0YREArXA8_8ZfrDO0JYLy8tikSHBEbzo,377
7
- gismap/lab/graph.py,sha256=LOHNnmFqgsZc7YGUcFQ1GKl0DFiStFfoYqx-2IrjFAk,6525
8
- gismap/lab/lab.py,sha256=-mBcHcP9JaBAiiZlWRygac5MQdO0b6AriHWiLgTveWc,4224
9
- gismap/lab/lip6.py,sha256=yRx-RWgcGhGWUk_oyfgC9QYJSVnATnp6YlNvaOlr8Gw,1410
10
- gismap/lab/toulouse.py,sha256=KkzNOCFt3OU6pDJmDmli6wRNuMwH8CPXHj_S6aOcYeg,1462
11
- gismap/lab/vis.py,sha256=1QgLgLQjcB7rGiZ946lhLU1kR38oXp_Y8l8U-Ukn65k,5497
12
- gismap/sources/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- gismap/sources/dblp.py,sha256=5ZKngU66xgXffmiGHsbXGXJfU_NIybnuzXXZPcWIZoE,5381
14
- gismap/sources/hal.py,sha256=mWyiG12wXE9A8w81YGFicx8Yy9mX-anvIEoBueU2U6Q,9136
15
- gismap/sources/models.py,sha256=yJPBXcJO6MgOrSXgpGPepHDDtniJP1OsK8OSz__VzYc,543
16
- gismap/sources/multi.py,sha256=jfvBVgmnLT85RaEWcMNCZ8YtmSRuQuq8CkCHWY8u-hc,3515
17
- gismap/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
- gismap/utils/common.py,sha256=BV5mma4aikHyPIhH4theLkiNHaiqLv5_EfxhT0yajZo,1509
19
- gismap/utils/logger.py,sha256=1YALIaNYKTqeIyyCnYxzvZTK7x4FTSfYYl5CP9IMw8E,86
20
- gismap/utils/requests.py,sha256=DV5rmyuy7jpMp63kzGXe848pmwMb5397wGHgF0o_0BM,721
21
- gismap/utils/text.py,sha256=R7tKWevfF4g-LsohF6FeiRdCuNYz4jQ1VcQJIyhwei0,2393
22
- gismap-0.1.0.dist-info/METADATA,sha256=bTM9vZl81oJ5dUYakrCEL1uAbTZzEgC1AGSePg1TBU8,2499
23
- gismap-0.1.0.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
24
- gismap-0.1.0.dist-info/licenses/AUTHORS.md,sha256=oDR4mptVUBMq0WKIpt19Km1Bdfz3cO2NAOVgwVfTO8g,131
25
- gismap-0.1.0.dist-info/RECORD,,
File without changes