Razkaroth commited on
Commit
f44b640
·
1 Parent(s): dc11b1d

runs the app

Browse files
Files changed (4) hide show
  1. .gitignore +162 -0
  2. app.py +102 -0
  3. requirements.txt +50 -0
  4. shell.nix +62 -0
.gitignore ADDED
@@ -0,0 +1,162 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # poetry
98
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
102
+ #poetry.lock
103
+
104
+ # pdm
105
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
106
+ #pdm.lock
107
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
108
+ # in version control.
109
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
110
+ .pdm.toml
111
+ .pdm-python
112
+ .pdm-build/
113
+
114
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
115
+ __pypackages__/
116
+
117
+ # Celery stuff
118
+ celerybeat-schedule
119
+ celerybeat.pid
120
+
121
+ # SageMath parsed files
122
+ *.sage.py
123
+
124
+ # Environments
125
+ .env
126
+ .venv
127
+ env/
128
+ venv/
129
+ ENV/
130
+ env.bak/
131
+ venv.bak/
132
+
133
+ # Spyder project settings
134
+ .spyderproject
135
+ .spyproject
136
+
137
+ # Rope project settings
138
+ .ropeproject
139
+
140
+ # mkdocs documentation
141
+ /site
142
+
143
+ # mypy
144
+ .mypy_cache/
145
+ .dmypy.json
146
+ dmypy.json
147
+
148
+ # Pyre type checker
149
+ .pyre/
150
+
151
+ # pytype static type analyzer
152
+ .pytype/
153
+
154
+ # Cython debug symbols
155
+ cython_debug/
156
+
157
+ # PyCharm
158
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
159
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
160
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
161
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
162
+ #.idea/
app.py ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import streamlit as st
2
+ import requests as req
3
+ import pandas as pd
4
+ st.set_page_config(page_title="PREP exporter", page_icon=":shark:", layout="wide")
5
+
6
+
7
+ st.title("PREP exporter")
8
+
9
+ candidatos = req.get("https://prepgto2024.ieeg.mx/assets/json/infoStaging.json").json()
10
+
11
+ # st.write(candidatos.keys())
12
+
13
+ canditatos_ayuntamientos = candidatos['ayuntamientos']['candidaturas']['candidatos']
14
+
15
+ candidatos_diputaciones = candidatos['diputaciones']['candidaturas']['candidatos']
16
+
17
+ # st.write(canditatos_ayuntamientos)
18
+ st.write('### IEEG ayuntamientos')
19
+ ayuntamientos = req.get("https://2024elecciones.s3.amazonaws.com/ayuntamientos2024.json").json()
20
+ # st.write(ayuntamientos['entidad']['entidad'][0])
21
+
22
+ data = ayuntamientos['entidad']['entidad']
23
+
24
+ dataset =[]
25
+ i = 0
26
+ for entidad in data:
27
+ candidatos_entidad = canditatos_ayuntamientos[i]
28
+ e = {
29
+ "entidad": entidad['nombreEntidad']
30
+ }
31
+ for candidato in candidatos_entidad:
32
+ e[candidato['partido'] + ' candidato'] = candidato['candidato']
33
+ for candidatura in entidad['votosCandidatura']['votos']:
34
+ e[candidatura['imagenPartidos'] + ' votos' ] = candidatura['votos']
35
+ e[candidatura['imagenPartidos'] + ' porcentaje' ] = candidatura['porcentaje']
36
+ dataset.append(e)
37
+ i += 1
38
+
39
+ df_ayuntamientos = pd.DataFrame(dataset)
40
+ ordered_columns = sorted(df_ayuntamientos.columns)
41
+ # send 'entidad' to the first column
42
+ ordered_columns.remove('entidad')
43
+ ordered_columns.insert(0, 'entidad')
44
+ df_ayuntamientos = df_ayuntamientos.reindex(ordered_columns, axis=1)
45
+
46
+ st.write(df_ayuntamientos)
47
+
48
+ st.write('### IEEG diputaciones')
49
+
50
+ diputaciones = req.get("https://2024elecciones.s3.amazonaws.com/diputaciones2024.json").json()
51
+ distritos = {
52
+ 'DISTRITO 1': 'Dolores Hidalgo Cuna de la Independencia Nacional',
53
+ 'DISTRITO 2': 'San Luis de la Paz',
54
+ 'DISTRITO 3': 'León',
55
+ 'DISTRITO 4': 'León',
56
+ 'DISTRITO 5': 'León',
57
+ 'DISTRITO 6': 'León',
58
+ 'DISTRITO 7': 'León',
59
+ 'DISTRITO 8': 'Guanajuato',
60
+ 'DISTRITO 9': 'San Miguel de Allende',
61
+ 'DISTRITO 10': 'San Francisco del Rincón',
62
+ 'DISTRITO 11': 'Irapuato',
63
+ 'DISTRITO 12': 'Irapuato',
64
+ 'DISTRITO 13': 'Cortazar',
65
+ 'DISTRITO 14': 'Salamanca',
66
+ 'DISTRITO 15': 'Celaya',
67
+ 'DISTRITO 16': 'Celaya',
68
+ 'DISTRITO 17': 'Apaseo el Grande',
69
+ 'DISTRITO 18': 'Pénjamo',
70
+ 'DISTRITO 19': 'Valle de Santiago',
71
+ 'DISTRITO 20': 'Yuriria',
72
+ 'DISTRITO 21': 'León',
73
+ 'DISTRITO 22': 'Acámbaro'
74
+ }
75
+
76
+ data = diputaciones['entidad']['entidad']
77
+
78
+ dataset =[]
79
+
80
+ i = 0
81
+ for entidad in data:
82
+ candidatos_entidad = candidatos_diputaciones[i]
83
+ e = {
84
+ "distrito": distritos[entidad['nombreEntidad']]
85
+ }
86
+ for candidato in candidatos_entidad:
87
+ e[candidato['partido'] + ' candidato'] = candidato['candidato']
88
+ for candidatura in entidad['votosCandidatura']['votos']:
89
+ e[candidatura['imagenPartidos'] + ' votos' ] = candidatura['votos']
90
+ e[candidatura['imagenPartidos'] + ' porcentaje' ] = candidatura['porcentaje']
91
+ dataset.append(e)
92
+ i += 1
93
+
94
+ df_diputaciones = pd.DataFrame(dataset)
95
+ ordered_columns = sorted(df_diputaciones.columns)
96
+ # send 'entidad' to the first column
97
+
98
+ ordered_columns.remove('distrito')
99
+ ordered_columns.insert(0, 'distrito')
100
+ df_diputaciones = df_diputaciones.reindex(ordered_columns, axis=1)
101
+
102
+ st.write(df_diputaciones)
requirements.txt ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ altair==5.3.0
2
+ attrs==23.2.0
3
+ beautifulsoup4==4.12.3
4
+ blinker==1.8.2
5
+ brotlicffi==1.1.0.0
6
+ cachetools==5.3.3
7
+ certifi==2024.2.2
8
+ cffi==1.16.0
9
+ chardet==5.2.0
10
+ charset-normalizer==3.3.2
11
+ click==8.1.7
12
+ et_xmlfile==1.1.0
13
+ gitdb==4.0.11
14
+ GitPython==3.1.43
15
+ idna==3.6
16
+ Jinja2==3.1.4
17
+ jsonschema==4.22.0
18
+ jsonschema-specifications==2023.12.1
19
+ lxml==5.1.0
20
+ markdown-it-py==3.0.0
21
+ MarkupSafe==2.1.5
22
+ mdurl==0.1.2
23
+ numpy==1.26.4
24
+ openpyxl==3.1.2
25
+ packaging==24.0
26
+ pandas==2.2.1
27
+ pillow==10.3.0
28
+ protobuf==4.25.3
29
+ pyarrow==16.1.0
30
+ pycparser==2.21
31
+ pydeck==0.9.1
32
+ Pygments==2.18.0
33
+ python-dateutil==2.9.0.post0
34
+ pytz==2024.1
35
+ referencing==0.35.1
36
+ requests==2.31.0
37
+ rich==13.7.1
38
+ rpds-py==0.18.1
39
+ six==1.16.0
40
+ smmap==5.0.1
41
+ soupsieve==2.5
42
+ streamlit==1.35.0
43
+ tenacity==8.3.0
44
+ toml==0.10.2
45
+ toolz==0.12.1
46
+ tornado==6.4
47
+ typing_extensions==4.12.1
48
+ tzdata==2024.1
49
+ urllib3==2.2.1
50
+ watchdog==4.0.1
shell.nix ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ with import <nixpkgs> { };
2
+
3
+ let
4
+ pythonPackages = python3Packages;
5
+ in
6
+ pkgs.mkShell rec {
7
+ name = "impurePythonEnv";
8
+ venvDir = "./.venv";
9
+ myPythonPackages = with pythonPackages; [
10
+ # A Python interpreter including the 'venv' module is required to bootstrap
11
+ # the environment.
12
+ python
13
+ # This executes some shell code to initialize a venv in $venvDir before
14
+ # dropping into the shell
15
+ venvShellHook
16
+
17
+ # Those are dependencies that we would like to use from nixpkgs, which will
18
+ # add them to PYTHONPATH and thus make them accessible from within the venv.
19
+ pip
20
+ numpy
21
+ pandas
22
+ beautifulsoup4
23
+ lxml
24
+ openpyxl
25
+ requests
26
+ ];
27
+ buildInputs = [
28
+
29
+ myPythonPackages
30
+ # In this particular example, in order to compile any binary extensions they may
31
+ # require, the Python modules listed in the hypothetical requirements.txt need
32
+ # the following packages to be installed locally:
33
+ taglib
34
+ openssl
35
+ git
36
+ libxml2
37
+ libxslt
38
+ libzip
39
+ zlib
40
+ gcc-unwrapped.lib
41
+ ];
42
+
43
+
44
+ # Run this command, only after creating the virtual environment
45
+ postVenvCreation = ''
46
+ unset SOURCE_DATE_EPOCH
47
+ # check if there is a requirements.txt file
48
+ if test -f requirements.txt; then
49
+ # install the requirements
50
+ pip install -r requirements.txt
51
+ fi
52
+ '';
53
+
54
+ # Now we can execute any commands within the virtual environment.
55
+ # This is optional and can be left out to run pip manually.
56
+ postShellHook = ''
57
+ # allow pip to install wheels
58
+ unset SOURCE_DATE_EPOCH
59
+ fish
60
+ '';
61
+
62
+ }