inpython-package 1.0.7__py3-none-any.whl → 1.0.8__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.
inpython/aotools/aogeo.py CHANGED
@@ -1 +1,61 @@
1
- # base alwayson python tools #
1
+ """Always-On geocoding module
2
+
3
+ Content :
4
+ =========
5
+ distance_calculation : Calculate distance between 2 points or multiple points on earth
6
+ offset_calculation : Calculate one or more GPS coordinates from an initial point based on a given azimuth and distance
7
+ """
8
+
9
+ import geopy.distance
10
+ from latlon import *
11
+
12
+
13
+ def distance_calculation(origin, coordinates):
14
+ """Calculate distance between 2 points or multiple points on earth
15
+
16
+ Usage :
17
+ =======
18
+ origin (tuple) : The origin from which we want to calculate distances
19
+ coordinates (list) : Points used to calculate the distance
20
+
21
+ Example :
22
+ =========
23
+ distance_calculation((52.2296756, 21.0122287), [(52.406374, 16.9251681), (52.606374, 16.5251681)])
24
+ Output = [279.35290160430094, 308.0962131498814]
25
+ """
26
+ try:
27
+ return [geopy.distance.geodesic(
28
+ origin, coordinate).km for coordinate in coordinates]
29
+ except Exception as e:
30
+ raise e
31
+
32
+
33
+ def offset_calculation(origin, azimuths_and_distances):
34
+ """ Calculate one or more GPS coordinates from an initial point based on a given azimuth and distance
35
+
36
+ Usage :
37
+ =======
38
+ origin (tuple) : The origin from which we want to calculate offsets
39
+ azimuths_and_distances (list) : List of azimuths and distances
40
+
41
+ Example :
42
+ =========
43
+ offset_calculation((52.2296756, 21.0122287), [(0, 279.35290160430094), (50, 308.0962131498814)])
44
+ Output = 54.739690349825885,21.01222870000001|53.95616765233316,24.60854517315002
45
+ """
46
+ try:
47
+ origin = LatLon(Latitude(origin[0]), Longitude(origin[1]))
48
+ points = [origin.offset(azim, dist)
49
+ for azim, dist in azimuths_and_distances]
50
+ points = ["{0},{1}".format(point.lat, point.lon) for point in points]
51
+ return "|".join(points)
52
+ except Exception as e:
53
+ raise e
54
+
55
+
56
+ if __name__ == "__main__":
57
+ print("Hello from aogeo")
58
+ print(distance_calculation(
59
+ (52.2296756, 21.0122287), [(52.406374, 16.9251681), (52.606374, 16.5251681)]))
60
+ print(offset_calculation((52.2296756, 21.0122287), [
61
+ (0, 279.35290160430094), (50, 308.0962131498814)]))
@@ -1,4 +1,5 @@
1
1
  # infodata' u2python module to work with ..GRAPH... intools
2
+ # efv 20240403 elimine le finaly car cela efface les erreurs
2
3
  import sys
3
4
  import json
4
5
  import msal
@@ -46,8 +47,7 @@ def getGraphTokenFromCertificate(path):
46
47
  # try to get a token
47
48
  result = msal_app.acquire_token_for_client(scopes=config["scope"])
48
49
  result = json.dumps(result)
49
- return result
50
+ return result
50
51
  except:
51
52
  # toute exception issue de la séquence try arrive ici et est remontée à l'appelant 'uvpython'
52
53
  raise # pour que l'appelant reçoive l'exception
53
-
@@ -0,0 +1,58 @@
1
+ from docx import Document
2
+
3
+ def chk_br(par):
4
+ for run in par.r_lst:
5
+ if len(run.br_lst) > 0:
6
+ return(True)
7
+ return(False)
8
+
9
+ def build_word_file(doc_directory,fab_filename,skipped_pg_br,keeped_pg_br):
10
+ tmp_file = doc_directory + "/schemas.docx"
11
+
12
+ print(fab_filename)
13
+ doc_fab = Document(fab_filename)
14
+ doc_fab.save(tmp_file)
15
+ doc_tmp = Document(tmp_file)
16
+
17
+ # extraction des pages du docuemnt fabriquant
18
+ num_page_breaks = 0
19
+
20
+ state = 0
21
+
22
+ for elt_idx, elt in enumerate(doc_tmp.element.body):
23
+ print(elt.tag)
24
+ if state == 0:
25
+ if elt.tag == "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}p":
26
+ if chk_br(elt):
27
+ num_page_breaks += 1
28
+ if num_page_breaks == 2:
29
+ doc_tmp.save(tmp_file)
30
+ state = 1
31
+ doc_tmp.element.body.remove(elt)
32
+ elif state == 1:
33
+ if elt.tag == "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}p":
34
+ if chk_br(elt):
35
+ num_page_breaks += 1
36
+ if num_page_breaks == 3:
37
+ state = 2
38
+ doc_tmp.element.body.remove(elt)
39
+ #doc_tmp.add_paragraph()
40
+ #elif elt.tag == "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tbl":
41
+ #table_copy(elt, doc_fab, doc_tmp)
42
+ elif state == 2:
43
+ if elt.tag != "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}sectPr":
44
+ doc_tmp.element.body.remove(elt)
45
+
46
+ print("save " + tmp_file)
47
+ doc_tmp.save(tmp_file)
48
+
49
+ return(tmp_file)
50
+
51
+ def build_devis(doc_directory,fab_filename,startdoc,end_doc):
52
+ tmp_doc = build_word_file(doc_directory,fab_filename,2,1)
53
+ print(tmp_doc)
54
+
55
+ doc_dir = "Q:/is/chantier/1000/"
56
+ fab_fn = "Q:/is/chantier/1000/FABRIQUANT/1000.docx"
57
+
58
+ build_devis(doc_dir,fab_fn,"","")
@@ -0,0 +1,6 @@
1
+ # inpython.ingraph init file
2
+ # executed when 'from inpython.ingraph import *'
3
+
4
+ # !! update the list when new modules are added !!
5
+
6
+ __all__ = ["xls_to_csv", "in_projet", "in_docx","in_test"]
@@ -0,0 +1,61 @@
1
+ from docx import Document
2
+ from docxcompose.composer import Composer
3
+
4
+ def chk_br(par):
5
+ for run in par.r_lst:
6
+ if len(run.br_lst) > 0:
7
+ return(True)
8
+ return(False)
9
+
10
+ def doc_extract(doc_directory,fab_filename,skipped_pg_br,keeped_pg_br):
11
+ tmp_file = doc_directory + "/schemas.docx"
12
+
13
+ doc_fab = Document(fab_filename)
14
+ doc_fab.save(tmp_file)
15
+ doc_tmp = Document(tmp_file)
16
+
17
+ # extraction des pages du docuemnt fabriquant
18
+ num_page_breaks = 0
19
+
20
+ state = 0
21
+
22
+ for elt_idx, elt in enumerate(doc_tmp.element.body):
23
+ if state == 0:
24
+ if elt.tag == "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}p":
25
+ if chk_br(elt):
26
+ num_page_breaks += 1
27
+ if num_page_breaks == 2:
28
+ doc_tmp.save(tmp_file)
29
+ state = 1
30
+ doc_tmp.element.body.remove(elt)
31
+ elif state == 1:
32
+ if elt.tag == "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}p":
33
+ if chk_br(elt):
34
+ num_page_breaks += 1
35
+ if num_page_breaks == 3:
36
+ state = 2
37
+ doc_tmp.element.body.remove(elt)
38
+ #doc_tmp.add_paragraph()
39
+ #elif elt.tag == "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}tbl":
40
+ #table_copy(elt, doc_fab, doc_tmp)
41
+ elif state == 2:
42
+ if elt.tag != "{http://schemas.openxmlformats.org/wordprocessingml/2006/main}sectPr":
43
+ doc_tmp.element.body.remove(elt)
44
+
45
+ doc_tmp.save(tmp_file)
46
+
47
+ return(tmp_file)
48
+
49
+ def compose_doc(base_file,files_list,final_doc):
50
+ files_list = files_list.split(";")
51
+ master = Document(base_file)
52
+ composer = Composer(master)
53
+ for filename in files_list:
54
+ doc_temp = Document(filename)
55
+ composer.append(doc_temp)
56
+ composer.save(final_doc)
57
+ return
58
+
59
+ if __name__ == '__main__':
60
+ flist = ['//winprod/commun/is/chantier/1000/schemas.docx', '//winprod/commun/is/chantier/1000/1000_DETAIL.docx', '//winprod/commun/is/chantier/_doc_base/Formulaire_ALU_cgv.docx']
61
+ compose_doc('//winprod/commun/is/chantier/_doc_base/Formulaire_ALU_1-3.docx',flist,'//winprod/commun/is/chantier/1000/Devis.docx')
@@ -0,0 +1,55 @@
1
+ from docx import Document
2
+ from docx.shared import Pt
3
+ import csv
4
+
5
+ def hello_world():
6
+ print('Hello world fron in_projet')
7
+
8
+ def build_projet(txt_filename,tpl_filename,doc_filename):
9
+ doc_prj = Document(tpl_filename)
10
+ font_size = Pt(8)
11
+
12
+ ret = False
13
+ table = doc_prj.tables[0]
14
+
15
+ data = []
16
+ # Ouvrir le fichier en mode lecture
17
+ with open(txt_filename, 'r', encoding="utf-8") as file:
18
+ # Créer un lecteur CSV
19
+ reader = csv.reader(file, delimiter=';') # Spécifiez le délimiteur approprié si nécessaire
20
+ for rowidx, row in enumerate(reader):
21
+ if rowidx >= 11:
22
+ if len(row) > 0:
23
+ data.append(row)
24
+
25
+ current_pos = ''
26
+ for posidx, pos in enumerate(data[0]):
27
+ if pos != "X":
28
+ current_pos = data[1][posidx]
29
+ cells = table.add_row().cells
30
+ cells[0].text = data[1][posidx]
31
+ cells[0].paragraphs[0].runs[0].font.bold = True
32
+ text = str(data[4][posidx])
33
+ cells[1].text = text.replace("|","\r")
34
+ cells[2].text = data[3][posidx]
35
+ cells[3].text = data[13][posidx]
36
+ cells[4].text = data[5][posidx]
37
+ cells[5].text = data[11][posidx]
38
+ cells[6].text = data[12][posidx]
39
+
40
+ #else:
41
+ # print("desigantion = ",data[4][posidx])
42
+
43
+ for cell in table._cells:
44
+ for paragraph in cell.paragraphs:
45
+ for run in paragraph.runs:
46
+ run.font.size = font_size
47
+ run.font.name = 'Calibri'
48
+
49
+ doc_prj.save(doc_filename)
50
+ ret = True
51
+ return(ret)
52
+
53
+ if __name__ == '__main__':
54
+ arguments = sys.argv
55
+
@@ -0,0 +1,4 @@
1
+
2
+ def hello_world:
3
+ print("salut les aminches")
4
+ return("ça roule ma poule!")
@@ -0,0 +1,45 @@
1
+ import pandas as pd
2
+ import sys
3
+ import csv
4
+
5
+ def hello_world():
6
+ print('Hello world fron xls_to_csv')
7
+
8
+ def parse_csv(csv_file):
9
+ # Ouvrir le fichier CSV en mode lecture
10
+ with open(csv_file, newline='') as csvfile:
11
+ # Créer un lecteur CSV
12
+ lecteur_csv = csv.reader(csvfile, delimiter=';')
13
+ donnees = list(lecteur_csv)
14
+ # Parcourir chaque ligne du fichier CSV
15
+ for lindex, ligne in enumerate(donnees):
16
+ # Parcourir chaque cellule de la ligne
17
+ for cindex, cellule in enumerate(ligne):
18
+ if len(cellule) > 0:
19
+ donnees[lindex][cindex] = cellule.replace('\n','|')
20
+
21
+ with open(csv_file, 'w', newline='') as fichier_sortie:
22
+ writer_csv = csv.writer(fichier_sortie, delimiter=';')
23
+ # Écrire les données modifiées dans le nouveau fichier CSV
24
+ writer_csv.writerows(donnees)
25
+
26
+
27
+ def convert_to_csv(xls_file,csv_file):
28
+ df = pd.read_excel(xls_file)
29
+ df.to_csv(csv_file, index=False, sep=';')
30
+ parse_csv(csv_file)
31
+ return
32
+
33
+ if __name__ == '__main__':
34
+ arguments = sys.argv
35
+
36
+ if len(arguments) == 3:
37
+ xl_filename = arguments[1].replace('\\','/') # Premier argument
38
+ csv_filename = arguments[2].replace('\\','/') # Deuxième argument
39
+ convert_to_csv(xl_filename, csv_filename)
40
+ else:
41
+ xl_filename = "Q:/is/chantier/1000/1000_DETAIL.xlsx" # Premier argument
42
+ csv_filename = "Q:/is/chantier/1000/1000_DETAIL.csv" # Deuxième argument
43
+ convert_to_csv(xl_filename, csv_filename)
44
+ print("Veuillez spécifier des arguments.")
45
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: inpython-package
3
- Version: 1.0.7
3
+ Version: 1.0.8
4
4
  Summary: # Infodata's IN-Tools U2Python Package
5
5
  Home-page: https://bitbucket.org/infodata-dev/inpython
6
6
  Author: infodata
@@ -10,19 +10,22 @@ Requires-Python: >=3.4
10
10
  Description-Content-Type: text/markdown
11
11
  License-File: LICENSE.txt
12
12
  Requires-Dist: msal >=1.22
13
+ Requires-Dist: qrcode
13
14
 
14
- # README #
15
+ # README
15
16
 
16
17
  Ce projet **inpython-package** rassemble tous les packages et modules python exploités par Integrix .
17
18
 
18
- # sub-package **inpython.ingraph**
19
+ ## sub-package **inpython.ingraph**
20
+
19
21
  package pour la gestion avec MS-Graph en exploitant le module 'msal' (Microsoft Authentication Library).
20
22
 
21
- ### How do I get set up? ###
23
+ ## How do I get set up?
22
24
 
23
25
  * Les bases de u2Python c.f. [wiki sys/proc/install u2Python](https://wiki.infodata.lu/sys/proc/install_u2python)
24
26
  * [U2Python par RocketSoftware](https://docs.rocketsoftware.com/bundle/UniVerse_PythonUserGuide_V1134/resource/UniVerse_PythonUserGuide_V1134.pdf)
25
- * Vérifier la version de u2Python, au TCL uv
27
+ * Vérifier la version de u2Python, au TCL uv
28
+
26
29
  ```python
27
30
  >python
28
31
  import sys
@@ -32,9 +35,10 @@ print('\n'.join(sys.path)) # les path en cours
32
35
  exit()
33
36
  ```
34
37
 
35
- ### Install inPackages into U2python
36
- - `pip3 install inpython-package`
38
+ ## Install inPackages into U2python
39
+
40
+ * `pip3 install inpython-package`
37
41
 
38
- ### Manage Package
39
- - c.f. [devREADME](devREADME.md)
42
+ ## Manage Package
40
43
 
44
+ * c.f. [devREADME](devREADME.md)
@@ -0,0 +1,17 @@
1
+ inpython/__init__.py,sha256=ZZMTm5QeMRlmewa5jmhBldUYnLX-ZbLxLut_PyXHFmw,47
2
+ inpython/__main__.py,sha256=_WTI7FZVtIi59VDIyBe4IL0mii4TWinjfmPNxNc7Fy0,30
3
+ inpython/aotools/__init__.py,sha256=394QRN-l_cGTB2KGZCGbid1Xpn5wZiNTNsacE7cuDus,160
4
+ inpython/aotools/aogeo.py,sha256=newQA1r7tpnofjtXOIzbIeNAxaMXCG-05AxGGImBpeo,2222
5
+ inpython/ingraph/__init__.py,sha256=FMGklQI9h9OL3qvXadTPja-WUZkS5ugdzZCNQhtuKq0,162
6
+ inpython/ingraph/ingraph.py,sha256=8r_4GhEoohC7mO00SRUucc6rqSGMjrJ5PK5BdInyEto,2088
7
+ inpython/intools/Servalux-devis.py,sha256=CYDSgzUc6vm51Y9M1-JyJivMePaGWSdJ4T7tfl37Xsk,1948
8
+ inpython/intools/__init__.py,sha256=2071aXyAithSsfce3MixbMR3cHi2iGa6a4y4ggy97GI,193
9
+ inpython/intools/in_docx.py,sha256=pn4ydO1P0adKF3w-I4be8IsA6eobq6xGO8SlsxDJyxM,2288
10
+ inpython/intools/in_projet.py,sha256=7rRZkui48Ktyz8oZ0TiKXh0QDVkiOaCbsbBVwSpCzVw,1758
11
+ inpython/intools/in_test.py,sha256=JLtAYxVr0HS1SIz0TTS7rChvD06_c-ydFHV1BWhQcK4,83
12
+ inpython/intools/xls_to_csv.py,sha256=6yEO6lRdnfRPwV7Tqd6_xzmeScL2T_sHKM3sifM-fus,1613
13
+ inpython_package-1.0.8.dist-info/LICENSE.txt,sha256=IirBHVsB--MNPRVyUzq8A99ot9-F-IiAW2t2auIxJDA,1092
14
+ inpython_package-1.0.8.dist-info/METADATA,sha256=qaEf8OptODvGppRtmsNJTAaoK26yZlQtt9fv8aVbzAg,1294
15
+ inpython_package-1.0.8.dist-info/WHEEL,sha256=Z4pYXqR_rTB7OWNDYFOm1qRk0RX6GFP2o8LgvP453Hk,91
16
+ inpython_package-1.0.8.dist-info/top_level.txt,sha256=cY6uggTAnozInE_EbHweIn8VjImvJcHc1w9WK4kYmXI,9
17
+ inpython_package-1.0.8.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.43.0)
2
+ Generator: setuptools (70.3.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,11 +0,0 @@
1
- inpython/__init__.py,sha256=ZZMTm5QeMRlmewa5jmhBldUYnLX-ZbLxLut_PyXHFmw,47
2
- inpython/__main__.py,sha256=_WTI7FZVtIi59VDIyBe4IL0mii4TWinjfmPNxNc7Fy0,30
3
- inpython/aotools/__init__.py,sha256=394QRN-l_cGTB2KGZCGbid1Xpn5wZiNTNsacE7cuDus,160
4
- inpython/aotools/aogeo.py,sha256=ViZoeUgpNTeelAPzoLZRqGh9INoe5dOER4XWFpDds80,33
5
- inpython/ingraph/__init__.py,sha256=FMGklQI9h9OL3qvXadTPja-WUZkS5ugdzZCNQhtuKq0,162
6
- inpython/ingraph/ingraph.py,sha256=uUomSwnLwJ18Altqxnbb--Zpvyspw20KGXSZVCovPMk,2029
7
- inpython_package-1.0.7.dist-info/LICENSE.txt,sha256=IirBHVsB--MNPRVyUzq8A99ot9-F-IiAW2t2auIxJDA,1092
8
- inpython_package-1.0.7.dist-info/METADATA,sha256=PiQFwMJkd7htM-MCce0pIXhM_806x56YhXVGhN2C7OE,1277
9
- inpython_package-1.0.7.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
10
- inpython_package-1.0.7.dist-info/top_level.txt,sha256=cY6uggTAnozInE_EbHweIn8VjImvJcHc1w9WK4kYmXI,9
11
- inpython_package-1.0.7.dist-info/RECORD,,