gilzero commited on
Commit
cb1a5c9
·
verified ·
1 Parent(s): 498d1da

Upload folder using huggingface_hub

Browse files
This view is limited to 50 files because it contains too many changes.   See raw diff
Files changed (50) hide show
  1. .env +12 -0
  2. .gitattributes +61 -35
  3. .idea/.gitignore +6 -0
  4. .idea/editor-app-v10.iml +14 -0
  5. .idea/inspectionProfiles/Project_Default.xml +6 -0
  6. .idea/inspectionProfiles/profiles_settings.xml +6 -0
  7. .idea/misc.xml +7 -0
  8. .idea/modules.xml +8 -0
  9. .idea/vcs.xml +6 -0
  10. README.md +4 -8
  11. __pycache__/analysis_config.cpython-310.pyc +0 -0
  12. __pycache__/analysis_config.cpython-312.pyc +0 -0
  13. __pycache__/analysis_runner.cpython-310.pyc +0 -0
  14. __pycache__/analysis_runner.cpython-312.pyc +0 -0
  15. __pycache__/document_processor.cpython-310.pyc +0 -0
  16. __pycache__/document_processor.cpython-312.pyc +0 -0
  17. __pycache__/language_models.cpython-310.pyc +0 -0
  18. __pycache__/language_models.cpython-312.pyc +0 -0
  19. __pycache__/log_config.cpython-310.pyc +0 -0
  20. __pycache__/log_config.cpython-312.pyc +0 -0
  21. __pycache__/model_selector.cpython-310.pyc +0 -0
  22. __pycache__/model_selector.cpython-312.pyc +0 -0
  23. __pycache__/text_analyzer.cpython-310.pyc +0 -0
  24. __pycache__/text_analyzer.cpython-312.pyc +0 -0
  25. analysis_config.py +99 -0
  26. analysis_logs.log +0 -0
  27. analysis_runner.py +72 -0
  28. app.py +57 -0
  29. document_processor.py +95 -0
  30. language_models.py +134 -0
  31. log_config.py +44 -0
  32. model_selector.py +68 -0
  33. myenv/bin/Activate.ps1 +247 -0
  34. myenv/bin/activate +69 -0
  35. myenv/bin/activate.csh +26 -0
  36. myenv/bin/activate.fish +69 -0
  37. myenv/bin/distro +8 -0
  38. myenv/bin/dotenv +8 -0
  39. myenv/bin/email_validator +8 -0
  40. myenv/bin/f2py +8 -0
  41. myenv/bin/fastapi +8 -0
  42. myenv/bin/fonttools +8 -0
  43. myenv/bin/gradio +8 -0
  44. myenv/bin/httpx +8 -0
  45. myenv/bin/huggingface-cli +8 -0
  46. myenv/bin/jsondiff +41 -0
  47. myenv/bin/jsonpatch +107 -0
  48. myenv/bin/jsonpointer +67 -0
  49. myenv/bin/jsonschema +8 -0
  50. myenv/bin/langsmith +8 -0
.env ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ OPENAI_API_KEY=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
2
+ ANTHROPIC_API_KEY=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
3
+ GOOGLE_API_KEY=AIzaSyDEVWQcOv_7OrkpP3GPGqSCyTjlAtRB5iE
4
+ MODEL_NAME_GPT4=gpt-4o
5
+ MODEL_NAME_CLAUDE_OPUS=claude-3-opus-20240229
6
+ MODEL_NAME_GEMINI_PRO=gemini-1.5-pro-latest
7
+ SECRET_KEY=your_secret_key
8
+ WHITELIST_IPS=127.0.0.1
9
+ WHITELIST_DOMAINS=localhost,example.com,subdomain.example.com,localhost:3000
10
+ GPT4_TOKEN_LIMIT=0
11
+ CLAUDE_TOKEN_LIMIT=199999
12
+ GEMINI_TOKEN_LIMIT=1000000
.gitattributes CHANGED
@@ -1,35 +1,61 @@
1
- *.7z filter=lfs diff=lfs merge=lfs -text
2
- *.arrow filter=lfs diff=lfs merge=lfs -text
3
- *.bin filter=lfs diff=lfs merge=lfs -text
4
- *.bz2 filter=lfs diff=lfs merge=lfs -text
5
- *.ckpt filter=lfs diff=lfs merge=lfs -text
6
- *.ftz filter=lfs diff=lfs merge=lfs -text
7
- *.gz filter=lfs diff=lfs merge=lfs -text
8
- *.h5 filter=lfs diff=lfs merge=lfs -text
9
- *.joblib filter=lfs diff=lfs merge=lfs -text
10
- *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
- *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
- *.model filter=lfs diff=lfs merge=lfs -text
13
- *.msgpack filter=lfs diff=lfs merge=lfs -text
14
- *.npy filter=lfs diff=lfs merge=lfs -text
15
- *.npz filter=lfs diff=lfs merge=lfs -text
16
- *.onnx filter=lfs diff=lfs merge=lfs -text
17
- *.ot filter=lfs diff=lfs merge=lfs -text
18
- *.parquet filter=lfs diff=lfs merge=lfs -text
19
- *.pb filter=lfs diff=lfs merge=lfs -text
20
- *.pickle filter=lfs diff=lfs merge=lfs -text
21
- *.pkl filter=lfs diff=lfs merge=lfs -text
22
- *.pt filter=lfs diff=lfs merge=lfs -text
23
- *.pth filter=lfs diff=lfs merge=lfs -text
24
- *.rar filter=lfs diff=lfs merge=lfs -text
25
- *.safetensors filter=lfs diff=lfs merge=lfs -text
26
- saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
- *.tar.* filter=lfs diff=lfs merge=lfs -text
28
- *.tar filter=lfs diff=lfs merge=lfs -text
29
- *.tflite filter=lfs diff=lfs merge=lfs -text
30
- *.tgz filter=lfs diff=lfs merge=lfs -text
31
- *.wasm filter=lfs diff=lfs merge=lfs -text
32
- *.xz filter=lfs diff=lfs merge=lfs -text
33
- *.zip filter=lfs diff=lfs merge=lfs -text
34
- *.zst filter=lfs diff=lfs merge=lfs -text
35
- *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Auto detect text files and perform LF normalization
2
+ * text=auto
3
+ myenv/bin/python filter=lfs diff=lfs merge=lfs -text
4
+ myenv/bin/python3 filter=lfs diff=lfs merge=lfs -text
5
+ myenv/bin/python3.10 filter=lfs diff=lfs merge=lfs -text
6
+ myenv/bin/ruff filter=lfs diff=lfs merge=lfs -text
7
+ myenv/lib/python3.10/site-packages/PIL/_imaging.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
8
+ myenv/lib/python3.10/site-packages/PyPDF2/_codecs/__pycache__/adobe_glyphs.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
9
+ myenv/lib/python3.10/site-packages/altair/vegalite/v5/schema/__pycache__/channels.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
10
+ myenv/lib/python3.10/site-packages/altair/vegalite/v5/schema/__pycache__/core.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
11
+ myenv/lib/python3.10/site-packages/dateutil/zoneinfo/dateutil-zoneinfo.tar.gz filter=lfs diff=lfs merge=lfs -text
12
+ myenv/lib/python3.10/site-packages/distutils-precedence.pth filter=lfs diff=lfs merge=lfs -text
13
+ myenv/lib/python3.10/site-packages/fontTools/feaLib/lexer.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
14
+ myenv/lib/python3.10/site-packages/fontTools/misc/bezierTools.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
15
+ myenv/lib/python3.10/site-packages/fontTools/pens/momentsPen.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
16
+ myenv/lib/python3.10/site-packages/fontTools/qu2cu/qu2cu.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
17
+ myenv/lib/python3.10/site-packages/fontTools/varLib/iup.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
18
+ myenv/lib/python3.10/site-packages/google_generativeai-0.5.4-py3.11-nspkg.pth filter=lfs diff=lfs merge=lfs -text
19
+ myenv/lib/python3.10/site-packages/gradio/frpc_linux_amd64_v0.2 filter=lfs diff=lfs merge=lfs -text
20
+ myenv/lib/python3.10/site-packages/gradio/templates/frontend/assets/Index-CUTYDExL.js.map filter=lfs diff=lfs merge=lfs -text
21
+ myenv/lib/python3.10/site-packages/grpc/_cython/cygrpc.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
22
+ myenv/lib/python3.10/site-packages/kiwisolver/_cext.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
23
+ myenv/lib/python3.10/site-packages/lxml/etree.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
24
+ myenv/lib/python3.10/site-packages/lxml/objectify.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
25
+ myenv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/axes_grid/bivariate_normal.npy filter=lfs diff=lfs merge=lfs -text
26
+ myenv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/goog.npz filter=lfs diff=lfs merge=lfs -text
27
+ myenv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/jacksboro_fault_dem.npz filter=lfs diff=lfs merge=lfs -text
28
+ myenv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/s1045.ima.gz filter=lfs diff=lfs merge=lfs -text
29
+ myenv/lib/python3.10/site-packages/matplotlib/mpl-data/sample_data/topobathy.npz filter=lfs diff=lfs merge=lfs -text
30
+ myenv/lib/python3.10/site-packages/numpy/core/_multiarray_umath.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
31
+ myenv/lib/python3.10/site-packages/numpy/core/_simd.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
32
+ myenv/lib/python3.10/site-packages/numpy/core/tests/data/astype_copy.pkl filter=lfs diff=lfs merge=lfs -text
33
+ myenv/lib/python3.10/site-packages/numpy/core/tests/data/numpy_2_0_array.pkl filter=lfs diff=lfs merge=lfs -text
34
+ myenv/lib/python3.10/site-packages/numpy/lib/tests/data/py2-objarr.npy filter=lfs diff=lfs merge=lfs -text
35
+ myenv/lib/python3.10/site-packages/numpy/lib/tests/data/py2-objarr.npz filter=lfs diff=lfs merge=lfs -text
36
+ myenv/lib/python3.10/site-packages/numpy/lib/tests/data/py3-objarr.npy filter=lfs diff=lfs merge=lfs -text
37
+ myenv/lib/python3.10/site-packages/numpy/lib/tests/data/py3-objarr.npz filter=lfs diff=lfs merge=lfs -text
38
+ myenv/lib/python3.10/site-packages/numpy/lib/tests/data/python3.npy filter=lfs diff=lfs merge=lfs -text
39
+ myenv/lib/python3.10/site-packages/numpy/lib/tests/data/win64python2.npy filter=lfs diff=lfs merge=lfs -text
40
+ myenv/lib/python3.10/site-packages/numpy.libs/libgfortran-040039e1.so.5.0.0 filter=lfs diff=lfs merge=lfs -text
41
+ myenv/lib/python3.10/site-packages/numpy.libs/libopenblas64_p-r0-0cf96a72.3.23.dev.so filter=lfs diff=lfs merge=lfs -text
42
+ myenv/lib/python3.10/site-packages/pandas/_libs/algos.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
43
+ myenv/lib/python3.10/site-packages/pandas/_libs/groupby.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
44
+ myenv/lib/python3.10/site-packages/pandas/_libs/hashtable.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
45
+ myenv/lib/python3.10/site-packages/pandas/_libs/interval.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
46
+ myenv/lib/python3.10/site-packages/pandas/_libs/join.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
47
+ myenv/lib/python3.10/site-packages/pandas/_libs/tslibs/offsets.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
48
+ myenv/lib/python3.10/site-packages/pillow.libs/libfreetype-1f2cdfbb.so.6.20.1 filter=lfs diff=lfs merge=lfs -text
49
+ myenv/lib/python3.10/site-packages/pillow.libs/libharfbuzz-8b0b6641.so.0.60840.0 filter=lfs diff=lfs merge=lfs -text
50
+ myenv/lib/python3.10/site-packages/pydantic_core/_pydantic_core.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
51
+ myenv/lib/python3.10/site-packages/pymupdf/__pycache__/mupdf.cpython-310.pyc filter=lfs diff=lfs merge=lfs -text
52
+ myenv/lib/python3.10/site-packages/pymupdf/_mupdf.so filter=lfs diff=lfs merge=lfs -text
53
+ myenv/lib/python3.10/site-packages/pymupdf/libmupdf.so.24.2 filter=lfs diff=lfs merge=lfs -text
54
+ myenv/lib/python3.10/site-packages/pymupdf/libmupdfcpp.so.24.2 filter=lfs diff=lfs merge=lfs -text
55
+ myenv/lib/python3.10/site-packages/regex/_regex.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
56
+ myenv/lib/python3.10/site-packages/rpds/rpds.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
57
+ myenv/lib/python3.10/site-packages/tiktoken/_tiktoken.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
58
+ myenv/lib/python3.10/site-packages/tokenizers/tokenizers.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
59
+ myenv/lib/python3.10/site-packages/uvloop/loop.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
60
+ myenv/lib/python3.10/site-packages/watchfiles/_rust_notify.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
61
+ myenv/lib/python3.10/site-packages/yaml/_yaml.cpython-310-x86_64-linux-gnu.so filter=lfs diff=lfs merge=lfs -text
.idea/.gitignore ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ # Default ignored files
2
+ /shelf/
3
+ /workspace.xml
4
+ # Datasource local storage ignored files
5
+ /dataSources/
6
+ /dataSources.local.xml
.idea/editor-app-v10.iml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <module type="PYTHON_MODULE" version="4">
3
+ <component name="NewModuleRootManager">
4
+ <content url="file://$MODULE_DIR$">
5
+ <excludeFolder url="file://$MODULE_DIR$/venv" />
6
+ </content>
7
+ <orderEntry type="inheritedJdk" />
8
+ <orderEntry type="sourceFolder" forTests="false" />
9
+ </component>
10
+ <component name="PyDocumentationSettings">
11
+ <option name="format" value="GOOGLE" />
12
+ <option name="myDocStringFormat" value="Google" />
13
+ </component>
14
+ </module>
.idea/inspectionProfiles/Project_Default.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <profile version="1.0">
3
+ <option name="myName" value="Project Default" />
4
+ <inspection_tool class="Eslint" enabled="true" level="WARNING" enabled_by_default="true" />
5
+ </profile>
6
+ </component>
.idea/inspectionProfiles/profiles_settings.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <component name="InspectionProjectProfileManager">
2
+ <settings>
3
+ <option name="USE_PROJECT_PROFILE" value="false" />
4
+ <version value="1.0" />
5
+ </settings>
6
+ </component>
.idea/misc.xml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="Black">
4
+ <option name="sdkName" value="Python 3.12 (editor-app-v10)" />
5
+ </component>
6
+ <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.12 (editor-app-v10)" project-jdk-type="Python SDK" />
7
+ </project>
.idea/modules.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="ProjectModuleManager">
4
+ <modules>
5
+ <module fileurl="file://$PROJECT_DIR$/.idea/editor-app-v10.iml" filepath="$PROJECT_DIR$/.idea/editor-app-v10.iml" />
6
+ </modules>
7
+ </component>
8
+ </project>
.idea/vcs.xml ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <project version="4">
3
+ <component name="VcsDirectoryMappings">
4
+ <mapping directory="$PROJECT_DIR$" vcs="Git" />
5
+ </component>
6
+ </project>
README.md CHANGED
@@ -1,12 +1,8 @@
1
  ---
2
- title: Editor App V10
3
- emoji: 🏢
4
- colorFrom: red
5
- colorTo: pink
6
  sdk: gradio
7
  sdk_version: 4.36.1
8
- app_file: app.py
9
- pinned: false
10
  ---
11
-
12
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
1
  ---
2
+ title: editor-app-v10
3
+ app_file: app.py
 
 
4
  sdk: gradio
5
  sdk_version: 4.36.1
 
 
6
  ---
7
+ # editor-app-v10
8
+
__pycache__/analysis_config.cpython-310.pyc ADDED
Binary file (2.88 kB). View file
 
__pycache__/analysis_config.cpython-312.pyc ADDED
Binary file (3.36 kB). View file
 
__pycache__/analysis_runner.cpython-310.pyc ADDED
Binary file (2.92 kB). View file
 
__pycache__/analysis_runner.cpython-312.pyc ADDED
Binary file (4.17 kB). View file
 
__pycache__/document_processor.cpython-310.pyc ADDED
Binary file (3.15 kB). View file
 
__pycache__/document_processor.cpython-312.pyc ADDED
Binary file (4.58 kB). View file
 
__pycache__/language_models.cpython-310.pyc ADDED
Binary file (4.11 kB). View file
 
__pycache__/language_models.cpython-312.pyc ADDED
Binary file (6.06 kB). View file
 
__pycache__/log_config.cpython-310.pyc ADDED
Binary file (1.1 kB). View file
 
__pycache__/log_config.cpython-312.pyc ADDED
Binary file (1.46 kB). View file
 
__pycache__/model_selector.cpython-310.pyc ADDED
Binary file (2.34 kB). View file
 
__pycache__/model_selector.cpython-312.pyc ADDED
Binary file (3.38 kB). View file
 
__pycache__/text_analyzer.cpython-310.pyc ADDED
Binary file (3.61 kB). View file
 
__pycache__/text_analyzer.cpython-312.pyc ADDED
Binary file (4.65 kB). View file
 
analysis_config.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filename: analysis_config.py
2
+
3
+ from log_config import get_logger
4
+
5
+ logger = get_logger('GetAnalysisPrompts')
6
+
7
+
8
+ def get_analysis_prompts(raw_text: str) -> dict:
9
+ """
10
+ Generate analysis prompts for a given text.
11
+
12
+ Args:
13
+ raw_text (str): The text to analyze.
14
+
15
+ Returns:
16
+ dict: A dictionary containing prompts for various types of analysis.
17
+ """
18
+ logger.info("Creating analysis prompts.")
19
+
20
+ prompt_template = (
21
+ "<prompt>\n"
22
+ " <task>{task} (output in Simplified Chinese):</task>\n"
23
+ " <text>{raw_text}</text>\n"
24
+ "{details}"
25
+ "</prompt>"
26
+ )
27
+
28
+ prompts = {
29
+ "Summary": prompt_template.format(
30
+ task="Provide a concise summary of this text",
31
+ raw_text=raw_text,
32
+ details=""
33
+ ),
34
+ "Characters": prompt_template.format(
35
+ task="Analyze the characters in this text",
36
+ raw_text=raw_text,
37
+ details=(
38
+ " <details>\n"
39
+ " Provide a list of major characters with brief descriptions of their personality traits and roles in the story.\n"
40
+ " Try to identify relationships between characters (friends, enemies, family, etc.).\n"
41
+ " Comment on any significant character development or arcs.\n"
42
+ " </details>\n"
43
+ )
44
+ ),
45
+ "Plot": prompt_template.format(
46
+ task="Analyze the plot structure of this text",
47
+ raw_text=raw_text,
48
+ details=(
49
+ " <details>\n"
50
+ " Try to identify key plot points (e.g., exposition, rising action, climax, falling action, resolution).\n"
51
+ " Outline the overall conflict or driving tension in the narrative.\n"
52
+ " </details>\n"
53
+ )
54
+ ),
55
+ "Themes": prompt_template.format(
56
+ task="Discuss the main themes explored in this text",
57
+ raw_text=raw_text,
58
+ details=(
59
+ " <details>\n"
60
+ " Identify and analyze the central ideas, messages, or insights the author seems to be conveying through the story.\n"
61
+ " Consider how these themes are developed and their significance.\n"
62
+ " </details>\n"
63
+ )
64
+ ),
65
+ "Techniques": prompt_template.format(
66
+ task="Analyze the writing techniques used in this text",
67
+ raw_text=raw_text,
68
+ details=(
69
+ " <details>\n"
70
+ " Look for notable examples of literary devices, narrative strategies, or stylistic choices the author employs.\n"
71
+ " Consider how these techniques contribute to the overall effect or meaning of the work.\n"
72
+ " </details>\n"
73
+ )
74
+ ),
75
+ "Emotional Core": prompt_template.format(
76
+ task="Discuss the emotional core of this text",
77
+ raw_text=raw_text,
78
+ details=(
79
+ " <details>\n"
80
+ " Identify the primary emotions evoked by the story and how the author elicits these feelings in the reader.\n"
81
+ " Consider the emotional journey of the characters and the reader's empathetic response.\n"
82
+ " </details>\n"
83
+ )
84
+ ),
85
+ "Narrative Perspective": prompt_template.format(
86
+ task="Analyze the narrative perspective used in this text",
87
+ raw_text=raw_text,
88
+ details=(
89
+ " <details>\n"
90
+ " Identify the point of view (e.g., first-person, third-person limited, omniscient) and consider how this perspective shapes the reader's understanding of events and characters.\n"
91
+ " </details>\n"
92
+ )
93
+ )
94
+ }
95
+
96
+ logger.info("Analysis prompts created successfully.")
97
+ return prompts
98
+
99
+ # file: analysis_config.py (end)
analysis_logs.log ADDED
The diff for this file is too large to render. See raw diff
 
analysis_runner.py ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filename: analysis_runner.py
2
+
3
+ """
4
+ Module for running text analysis in parallel with rate limiting.
5
+ """
6
+
7
+ from concurrent.futures import as_completed
8
+ from ratelimit import limits, RateLimitException
9
+ from log_config import get_logger
10
+
11
+ logger = get_logger('AnalysisRunner')
12
+
13
+ # Constants for rate limiting
14
+ RATE_LIMIT = 8 # Maximum number of concurrent requests
15
+ RATE_PERIOD = 1 # Rate period in seconds
16
+
17
+ # Apply the rate limiter decorator
18
+ calls = limits(calls=RATE_LIMIT, period=RATE_PERIOD)
19
+
20
+ def analyze_text_parallel(raw_text: str, selected_analyses: list, analysis_prompts: dict, optimal_models: list, thread_pool, progress) -> dict:
21
+ """
22
+ Run text analyses in parallel with rate limiting.
23
+
24
+ Args:
25
+ raw_text (str): The text to be analyzed.
26
+ selected_analyses (list): A list of selected analyses to perform.
27
+ analysis_prompts (dict): A dictionary containing analysis prompts.
28
+ optimal_models (list): A list of optimal models for each analysis.
29
+ thread_pool (concurrent.futures.Executor): The thread pool executor for running analyses.
30
+ progress (callable): A callable to report progress.
31
+
32
+ Returns:
33
+ dict: A dictionary with analysis results.
34
+ """
35
+ logger.debug(f"Selected Analyses: {selected_analyses}, Type: {type(selected_analyses)}")
36
+ logger.debug(f"Optimal Models: {optimal_models}, Type: {type(optimal_models)}")
37
+
38
+ analysis_results = {}
39
+ total_analyses = len(selected_analyses)
40
+ completed_analyses = 0
41
+
42
+ @calls
43
+ def run_analysis(analysis: str, model) -> tuple:
44
+ nonlocal completed_analyses
45
+ try:
46
+ prompt = analysis_prompts[analysis]
47
+ result = model.invoke(prompt)
48
+ logger.info(f"Analysis '{analysis}' completed successfully using {model.__class__.__name__}.")
49
+ completed_analyses += 1
50
+ progress(completed_analyses / total_analyses, desc=f"Analysis '{analysis}' completed.")
51
+ return analysis, result
52
+ except RateLimitException as e:
53
+ error_message = f"Rate limit exceeded for analysis '{analysis}' using {model.__class__.__name__}. Error: {str(e)}"
54
+ logger.warning(error_message)
55
+ return analysis, "Analysis failed due to rate limit exceeded."
56
+ except Exception as e:
57
+ error_message = f"Error running analysis '{analysis}' using {model.__class__.__name__}. Error type: {type(e).__name__}. Error message: {str(e)}"
58
+ logger.error(error_message, exc_info=True)
59
+ return analysis, f"Analysis failed due to an error: {str(e)}"
60
+
61
+ futures = {analysis: thread_pool.submit(run_analysis, analysis, model)
62
+ for analysis, model in zip(selected_analyses, optimal_models) if model}
63
+
64
+ for future in as_completed(futures.values()):
65
+ analysis, result = future.result()
66
+ analysis_results[analysis] = result
67
+ progress(completed_analyses / total_analyses, desc=f"Completed {completed_analyses}/{total_analyses} analyses.")
68
+
69
+ progress(1.0, desc="Analysis completed.")
70
+ return analysis_results
71
+
72
+ # file: analysis_runner.py (end)
app.py ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filename: app.py
2
+
3
+ import os
4
+ import gradio as gr
5
+ from dotenv import load_dotenv
6
+ from text_analyzer import TextAnalyzer
7
+ from log_config import get_logger
8
+
9
+ os.environ['GRADIO_ANALYTICS_ENABLED'] = 'False'
10
+ load_dotenv()
11
+
12
+ logger = get_logger('TextAnalysisAppV10')
13
+
14
+ def launch_gradio():
15
+ """
16
+ Initializes and launches a Gradio web interface for uploading documents and
17
+ performing text analysis. This interface allows users to upload files and
18
+ select types of text analysis to be performed on the uploaded document.
19
+ """
20
+ text_analyzer = TextAnalyzer()
21
+ available_analyses = ["Summary", "Characters", "Plot", "Themes", "Techniques", "Emotional Core", "Narrative Perspective"]
22
+
23
+ def process_input(file_path, selected_analyses, progress=gr.Progress()):
24
+ if not file_path:
25
+ return "Please upload a document to proceed."
26
+ if not selected_analyses:
27
+ return "Please select at least one type of analysis."
28
+ if any(analysis not in available_analyses for analysis in selected_analyses):
29
+ return f"Please choose valid options from: {', '.join(available_analyses)}."
30
+
31
+ try:
32
+ progress(0.0, desc="Starting analysis...")
33
+ results = text_analyzer.analyze_text(file_path, selected_analyses, progress)
34
+ progress(1.0, desc="Analysis completed.")
35
+ return results or "Analysis completed but no actionable results were found."
36
+ except Exception as e:
37
+ logger.error("Error processing document: %s", str(e), exc_info=True)
38
+ return "Please ensure the file is not corrupted and is in a supported format."
39
+
40
+ with gr.Blocks() as demo:
41
+ file_input = gr.File(label="Upload Your Document", type="filepath", file_types=["txt", "pdf", "docx"])
42
+ analysis_options = gr.CheckboxGroup(choices=available_analyses, label="Select Text Analysis Types")
43
+ output_text = gr.Textbox(label="Analysis Results", interactive=True)
44
+ submit_button = gr.Button("Analyze")
45
+
46
+ submit_button.click(
47
+ fn=process_input,
48
+ inputs=[file_input, analysis_options],
49
+ outputs=output_text
50
+ )
51
+
52
+ demo.launch(server_port=7880, share=True)
53
+
54
+ if __name__ == "__main__":
55
+ launch_gradio()
56
+
57
+ # file: app v10.py (end)
document_processor.py ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filename: document_processor.py
2
+
3
+ """
4
+ Module for extracting text from various document formats.
5
+ """
6
+
7
+ import io
8
+ import docx
9
+ from PyPDF2 import PdfReader
10
+ from log_config import get_logger
11
+
12
+ logger = get_logger('DocumentProcessor')
13
+
14
+ def extract_text_from_document(file_path: str) -> str:
15
+ """
16
+ Extracts text from a document based on its file extension.
17
+
18
+ Args:
19
+ file_path (str): The path to the file.
20
+
21
+ Returns:
22
+ str: The extracted text from the document.
23
+
24
+ Raises:
25
+ ValueError: If the file format is not supported.
26
+ """
27
+ file_extension = file_path.split(".")[-1].lower()
28
+ try:
29
+ with open(file_path, 'rb') as file_obj:
30
+ if file_extension == "txt":
31
+ return extract_text_from_txt(file_obj)
32
+ elif file_extension == "pdf":
33
+ return extract_text_from_pdf(file_obj)
34
+ elif file_extension == "docx":
35
+ return extract_text_from_docx(file_obj)
36
+ else:
37
+ raise ValueError(f"Unsupported file format: {file_extension}")
38
+ except Exception as e:
39
+ logger.error(f"Failed to extract text from {file_path}: {str(e)}")
40
+ raise
41
+
42
+ def extract_text_from_txt(file_obj: io.BufferedReader) -> str:
43
+ """
44
+ Extracts text from a text file.
45
+
46
+ Args:
47
+ file_obj (io.BufferedReader): The file object opened in binary mode.
48
+
49
+ Returns:
50
+ str: The decoded text.
51
+ """
52
+ try:
53
+ content = file_obj.read()
54
+ return content.decode('utf-8')
55
+ except UnicodeDecodeError as e:
56
+ logger.error(f"Unicode decode error: {str(e)}")
57
+ raise
58
+
59
+ def extract_text_from_pdf(file_obj: io.BufferedReader) -> str:
60
+ """
61
+ Extracts text from a PDF file.
62
+
63
+ Args:
64
+ file_obj (io.BufferedReader): The file object opened in binary mode.
65
+
66
+ Returns:
67
+ str: The concatenated text from all pages.
68
+ """
69
+ try:
70
+ reader = PdfReader(file_obj)
71
+ text = ''.join([page.extract_text() or '' for page in reader.pages])
72
+ return text.strip()
73
+ except Exception as e:
74
+ logger.error(f"Failed to extract text from PDF: {str(e)}")
75
+ raise
76
+
77
+ def extract_text_from_docx(file_obj: io.BufferedReader) -> str:
78
+ """
79
+ Extracts text from a DOCX file.
80
+
81
+ Args:
82
+ file_obj (io.BufferedReader): The file object opened in binary mode.
83
+
84
+ Returns:
85
+ str: The concatenated text from all paragraphs.
86
+ """
87
+ try:
88
+ doc = docx.Document(io.BytesIO(file_obj.read()))
89
+ text = '\n'.join(paragraph.text for paragraph in doc.paragraphs if paragraph.text)
90
+ return text.strip()
91
+ except Exception as e:
92
+ logger.error(f"Failed to extract text from DOCX: {str(e)}")
93
+ raise
94
+
95
+ # file: document_processor.py (end)
language_models.py ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filename: language_models.py
2
+
3
+ """
4
+ Module for defining various language model classes and their invocation methods.
5
+ """
6
+
7
+ import os
8
+ import logging
9
+ from abc import ABC, abstractmethod
10
+ from time import time
11
+ from langchain_openai import ChatOpenAI
12
+ from langchain_anthropic import ChatAnthropic
13
+ from langchain_google_genai import ChatGoogleGenerativeAI
14
+ from log_config import get_logger
15
+
16
+ # Configure logging
17
+ logger = get_logger('LanguageModels')
18
+
19
+ def get_api_key(service_name: str) -> str:
20
+ """
21
+ Retrieve the API key from environment variables.
22
+
23
+ Args:
24
+ service_name (str): The name of the service.
25
+
26
+ Returns:
27
+ str: The API key for the service.
28
+
29
+ Raises:
30
+ ValueError: If the API key is not set in environment variables.
31
+ """
32
+ api_key = os.getenv(service_name)
33
+ if not api_key:
34
+ logger.error(f"{service_name} environment variable not set.")
35
+ raise ValueError(f"API key for {service_name} is required")
36
+ return api_key
37
+
38
+ class LanguageModel(ABC):
39
+ """
40
+ Abstract base class for language models.
41
+ Defines a common interface for different AI language models.
42
+ """
43
+
44
+ @abstractmethod
45
+ def invoke(self, prompt: str) -> str:
46
+ """
47
+ Send a prompt to the language model and return the response.
48
+
49
+ Args:
50
+ prompt (str): The text prompt to send to the language model.
51
+
52
+ Returns:
53
+ str: The response from the language model.
54
+
55
+ Raises:
56
+ Exception: Propagates any exceptions that occur during invocation.
57
+ """
58
+ pass
59
+
60
+ class GPT4Model(LanguageModel):
61
+ """
62
+ A language model class for OpenAI's GPT-4.
63
+ """
64
+ def __init__(self):
65
+ api_key = get_api_key("OPENAI_API_KEY")
66
+ self.model = ChatOpenAI(
67
+ model=os.getenv('MODEL_NAME_GPT4', 'gpt-4o'),
68
+ temperature=0,
69
+ openai_api_key=api_key
70
+ )
71
+
72
+ def invoke(self, prompt: str) -> str:
73
+ if not prompt:
74
+ logger.error("Empty prompt provided.")
75
+ raise ValueError("Prompt cannot be empty.")
76
+ start_time = time()
77
+ try:
78
+ response = self.model.invoke([prompt])
79
+ logger.info(f"Invocation successful in {time() - start_time:.2f} seconds.")
80
+ return response
81
+ except Exception as e:
82
+ logger.error(f"Failed to invoke GPT-4 with prompt: '{prompt}', error: {str(e)}")
83
+ raise
84
+
85
+ class ClaudeModel(LanguageModel):
86
+ """
87
+ A language model class for Anthropic's Claude.
88
+ """
89
+ def __init__(self):
90
+ api_key = get_api_key("ANTHROPIC_API_KEY")
91
+ self.model = ChatAnthropic(
92
+ model=os.getenv('MODEL_NAME_CLAUDE_OPUS', 'claude-3-opus-20240229'),
93
+ temperature=0,
94
+ anthropic_api_key=api_key
95
+ )
96
+
97
+ def invoke(self, prompt: str) -> str:
98
+ if not prompt:
99
+ logger.error("Empty prompt provided.")
100
+ raise ValueError("Prompt cannot be empty.")
101
+ start_time = time()
102
+ try:
103
+ response = self.model.invoke([prompt])
104
+ logger.info(f"Invocation successful in {time() - start_time:.2f} seconds.")
105
+ return response
106
+ except Exception as e:
107
+ logger.error(f"Failed to invoke Claude with prompt: '{prompt}', error: {str(e)}")
108
+ raise
109
+
110
+ class GeminiModel(LanguageModel):
111
+ """
112
+ A language model class for Google's Generative AI, Gemini.
113
+ """
114
+ def __init__(self):
115
+ api_key = get_api_key("GOOGLE_API_KEY")
116
+ self.model = ChatGoogleGenerativeAI(
117
+ model=os.getenv('MODEL_NAME_GEMINI', 'gemini-1.5-pro-latest'),
118
+ api_key=api_key
119
+ )
120
+
121
+ def invoke(self, prompt: str) -> str:
122
+ if not prompt:
123
+ logger.error("Empty prompt provided.")
124
+ raise ValueError("Prompt cannot be empty.")
125
+ start_time = time()
126
+ try:
127
+ response = self.model.invoke([prompt])
128
+ logger.info(f"Invocation successful in {time() - start_time:.2f} seconds.")
129
+ return response
130
+ except Exception as e:
131
+ logger.error(f"Failed to invoke Gemini with prompt: '{prompt}', error: {str(e)}")
132
+ raise
133
+
134
+ # file: language_models.py (end)
log_config.py ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filename: log_config.py
2
+
3
+ """
4
+ Logging configuration module.
5
+
6
+ This module sets up the global logging configuration and provides a function to retrieve loggers with the given name.
7
+ """
8
+
9
+ import logging
10
+ from logging.handlers import RotatingFileHandler
11
+
12
+ # Configure the global logging settings
13
+ log_formatter = logging.Formatter(
14
+ fmt='%(asctime)s - %(name)s - %(levelname)s - %(message)s',
15
+ datefmt='%Y-%m-%d %H:%M:%S'
16
+ )
17
+
18
+ # File handler with rotation, set the rotation size to 5 MB
19
+ file_handler = RotatingFileHandler('analysis_logs.log', maxBytes=5*10**6, backupCount=3)
20
+ file_handler.setFormatter(log_formatter)
21
+
22
+ # Stream handler
23
+ stream_handler = logging.StreamHandler()
24
+ stream_handler.setFormatter(log_formatter)
25
+
26
+ # Setting up the root logger
27
+ logging.basicConfig(
28
+ level=logging.INFO,
29
+ handlers=[file_handler, stream_handler]
30
+ )
31
+
32
+ def get_logger(name: str) -> logging.Logger:
33
+ """
34
+ Retrieve a logger with the given name.
35
+
36
+ Args:
37
+ name (str): The name of the logger to retrieve.
38
+
39
+ Returns:
40
+ logging.Logger: A logger configured with global settings.
41
+ """
42
+ return logging.getLogger(name)
43
+
44
+ # file: log_config.py (end)
model_selector.py ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # filename: model_selector.py
2
+
3
+ from language_models import GPT4Model, ClaudeModel, GeminiModel, LanguageModel
4
+ import os
5
+ from tiktoken import get_encoding
6
+ from log_config import get_logger
7
+
8
+ logger = get_logger('ModelSelector')
9
+
10
+ # Load the tokenizer encoding
11
+ try:
12
+ encoding = get_encoding("cl100k_base")
13
+ except Exception as e:
14
+ logger.error("Failed to load encoding: %s", str(e))
15
+ raise
16
+
17
+ def count_tokens(text: str) -> int:
18
+ """Count the number of tokens in a text string.
19
+ Args:
20
+ text (str): The text string to count tokens in.
21
+ Returns:
22
+ int: The number of tokens in the text string.
23
+ """
24
+ return len(encoding.encode(text))
25
+
26
+ def select_optimal_model(raw_text: str) -> LanguageModel:
27
+ """Select the optimal language model for analyzing the given text based on token count.
28
+ Args:
29
+ raw_text (str): The text string to analyze.
30
+ Returns:
31
+ LanguageModel: The selected optimal language model instance.
32
+ """
33
+ if not isinstance(raw_text, str):
34
+ raise ValueError("Input text must be a string.")
35
+
36
+ try:
37
+ token_count = count_tokens(raw_text)
38
+ logger.info("Token count for input: %d", token_count)
39
+ except Exception as e:
40
+ logger.error("Error counting tokens: %s", str(e))
41
+ raise
42
+
43
+ # Token limits loaded from environment variables, with default values
44
+ model_preferences = {
45
+ GPT4Model: int(os.getenv('GPT4_TOKEN_LIMIT', '128000')),
46
+ ClaudeModel: int(os.getenv('CLAUDE_TOKEN_LIMIT', '199999')),
47
+ GeminiModel: int(os.getenv('GEMINI_TOKEN_LIMIT', '1000000'))
48
+ }
49
+
50
+ # Filter models that have sufficient token limit
51
+ available_models = sorted(
52
+ (model for model, limit in model_preferences.items() if token_count <= limit),
53
+ key=lambda model: model_preferences[model]
54
+ )
55
+
56
+ # Choose the first available model based on the sorted order
57
+ selected_model_class = available_models[0] if available_models else None
58
+
59
+ if selected_model_class:
60
+ selected_model = selected_model_class() # Create an instance of the selected model class
61
+ logger.info("Selected %s for analysis with token count of %d", selected_model.__class__.__name__, token_count)
62
+ else:
63
+ selected_model = None
64
+ logger.warning("No suitable model found for the given token count.")
65
+
66
+ return selected_model
67
+
68
+ # file: model_selector.py (end)
myenv/bin/Activate.ps1 ADDED
@@ -0,0 +1,247 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <#
2
+ .Synopsis
3
+ Activate a Python virtual environment for the current PowerShell session.
4
+
5
+ .Description
6
+ Pushes the python executable for a virtual environment to the front of the
7
+ $Env:PATH environment variable and sets the prompt to signify that you are
8
+ in a Python virtual environment. Makes use of the command line switches as
9
+ well as the `pyvenv.cfg` file values present in the virtual environment.
10
+
11
+ .Parameter VenvDir
12
+ Path to the directory that contains the virtual environment to activate. The
13
+ default value for this is the parent of the directory that the Activate.ps1
14
+ script is located within.
15
+
16
+ .Parameter Prompt
17
+ The prompt prefix to display when this virtual environment is activated. By
18
+ default, this prompt is the name of the virtual environment folder (VenvDir)
19
+ surrounded by parentheses and followed by a single space (ie. '(.venv) ').
20
+
21
+ .Example
22
+ Activate.ps1
23
+ Activates the Python virtual environment that contains the Activate.ps1 script.
24
+
25
+ .Example
26
+ Activate.ps1 -Verbose
27
+ Activates the Python virtual environment that contains the Activate.ps1 script,
28
+ and shows extra information about the activation as it executes.
29
+
30
+ .Example
31
+ Activate.ps1 -VenvDir C:\Users\MyUser\Common\.venv
32
+ Activates the Python virtual environment located in the specified location.
33
+
34
+ .Example
35
+ Activate.ps1 -Prompt "MyPython"
36
+ Activates the Python virtual environment that contains the Activate.ps1 script,
37
+ and prefixes the current prompt with the specified string (surrounded in
38
+ parentheses) while the virtual environment is active.
39
+
40
+ .Notes
41
+ On Windows, it may be required to enable this Activate.ps1 script by setting the
42
+ execution policy for the user. You can do this by issuing the following PowerShell
43
+ command:
44
+
45
+ PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
46
+
47
+ For more information on Execution Policies:
48
+ https://go.microsoft.com/fwlink/?LinkID=135170
49
+
50
+ #>
51
+ Param(
52
+ [Parameter(Mandatory = $false)]
53
+ [String]
54
+ $VenvDir,
55
+ [Parameter(Mandatory = $false)]
56
+ [String]
57
+ $Prompt
58
+ )
59
+
60
+ <# Function declarations --------------------------------------------------- #>
61
+
62
+ <#
63
+ .Synopsis
64
+ Remove all shell session elements added by the Activate script, including the
65
+ addition of the virtual environment's Python executable from the beginning of
66
+ the PATH variable.
67
+
68
+ .Parameter NonDestructive
69
+ If present, do not remove this function from the global namespace for the
70
+ session.
71
+
72
+ #>
73
+ function global:deactivate ([switch]$NonDestructive) {
74
+ # Revert to original values
75
+
76
+ # The prior prompt:
77
+ if (Test-Path -Path Function:_OLD_VIRTUAL_PROMPT) {
78
+ Copy-Item -Path Function:_OLD_VIRTUAL_PROMPT -Destination Function:prompt
79
+ Remove-Item -Path Function:_OLD_VIRTUAL_PROMPT
80
+ }
81
+
82
+ # The prior PYTHONHOME:
83
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PYTHONHOME) {
84
+ Copy-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME -Destination Env:PYTHONHOME
85
+ Remove-Item -Path Env:_OLD_VIRTUAL_PYTHONHOME
86
+ }
87
+
88
+ # The prior PATH:
89
+ if (Test-Path -Path Env:_OLD_VIRTUAL_PATH) {
90
+ Copy-Item -Path Env:_OLD_VIRTUAL_PATH -Destination Env:PATH
91
+ Remove-Item -Path Env:_OLD_VIRTUAL_PATH
92
+ }
93
+
94
+ # Just remove the VIRTUAL_ENV altogether:
95
+ if (Test-Path -Path Env:VIRTUAL_ENV) {
96
+ Remove-Item -Path env:VIRTUAL_ENV
97
+ }
98
+
99
+ # Just remove VIRTUAL_ENV_PROMPT altogether.
100
+ if (Test-Path -Path Env:VIRTUAL_ENV_PROMPT) {
101
+ Remove-Item -Path env:VIRTUAL_ENV_PROMPT
102
+ }
103
+
104
+ # Just remove the _PYTHON_VENV_PROMPT_PREFIX altogether:
105
+ if (Get-Variable -Name "_PYTHON_VENV_PROMPT_PREFIX" -ErrorAction SilentlyContinue) {
106
+ Remove-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Scope Global -Force
107
+ }
108
+
109
+ # Leave deactivate function in the global namespace if requested:
110
+ if (-not $NonDestructive) {
111
+ Remove-Item -Path function:deactivate
112
+ }
113
+ }
114
+
115
+ <#
116
+ .Description
117
+ Get-PyVenvConfig parses the values from the pyvenv.cfg file located in the
118
+ given folder, and returns them in a map.
119
+
120
+ For each line in the pyvenv.cfg file, if that line can be parsed into exactly
121
+ two strings separated by `=` (with any amount of whitespace surrounding the =)
122
+ then it is considered a `key = value` line. The left hand string is the key,
123
+ the right hand is the value.
124
+
125
+ If the value starts with a `'` or a `"` then the first and last character is
126
+ stripped from the value before being captured.
127
+
128
+ .Parameter ConfigDir
129
+ Path to the directory that contains the `pyvenv.cfg` file.
130
+ #>
131
+ function Get-PyVenvConfig(
132
+ [String]
133
+ $ConfigDir
134
+ ) {
135
+ Write-Verbose "Given ConfigDir=$ConfigDir, obtain values in pyvenv.cfg"
136
+
137
+ # Ensure the file exists, and issue a warning if it doesn't (but still allow the function to continue).
138
+ $pyvenvConfigPath = Join-Path -Resolve -Path $ConfigDir -ChildPath 'pyvenv.cfg' -ErrorAction Continue
139
+
140
+ # An empty map will be returned if no config file is found.
141
+ $pyvenvConfig = @{ }
142
+
143
+ if ($pyvenvConfigPath) {
144
+
145
+ Write-Verbose "File exists, parse `key = value` lines"
146
+ $pyvenvConfigContent = Get-Content -Path $pyvenvConfigPath
147
+
148
+ $pyvenvConfigContent | ForEach-Object {
149
+ $keyval = $PSItem -split "\s*=\s*", 2
150
+ if ($keyval[0] -and $keyval[1]) {
151
+ $val = $keyval[1]
152
+
153
+ # Remove extraneous quotations around a string value.
154
+ if ("'""".Contains($val.Substring(0, 1))) {
155
+ $val = $val.Substring(1, $val.Length - 2)
156
+ }
157
+
158
+ $pyvenvConfig[$keyval[0]] = $val
159
+ Write-Verbose "Adding Key: '$($keyval[0])'='$val'"
160
+ }
161
+ }
162
+ }
163
+ return $pyvenvConfig
164
+ }
165
+
166
+
167
+ <# Begin Activate script --------------------------------------------------- #>
168
+
169
+ # Determine the containing directory of this script
170
+ $VenvExecPath = Split-Path -Parent $MyInvocation.MyCommand.Definition
171
+ $VenvExecDir = Get-Item -Path $VenvExecPath
172
+
173
+ Write-Verbose "Activation script is located in path: '$VenvExecPath'"
174
+ Write-Verbose "VenvExecDir Fullname: '$($VenvExecDir.FullName)"
175
+ Write-Verbose "VenvExecDir Name: '$($VenvExecDir.Name)"
176
+
177
+ # Set values required in priority: CmdLine, ConfigFile, Default
178
+ # First, get the location of the virtual environment, it might not be
179
+ # VenvExecDir if specified on the command line.
180
+ if ($VenvDir) {
181
+ Write-Verbose "VenvDir given as parameter, using '$VenvDir' to determine values"
182
+ }
183
+ else {
184
+ Write-Verbose "VenvDir not given as a parameter, using parent directory name as VenvDir."
185
+ $VenvDir = $VenvExecDir.Parent.FullName.TrimEnd("\\/")
186
+ Write-Verbose "VenvDir=$VenvDir"
187
+ }
188
+
189
+ # Next, read the `pyvenv.cfg` file to determine any required value such
190
+ # as `prompt`.
191
+ $pyvenvCfg = Get-PyVenvConfig -ConfigDir $VenvDir
192
+
193
+ # Next, set the prompt from the command line, or the config file, or
194
+ # just use the name of the virtual environment folder.
195
+ if ($Prompt) {
196
+ Write-Verbose "Prompt specified as argument, using '$Prompt'"
197
+ }
198
+ else {
199
+ Write-Verbose "Prompt not specified as argument to script, checking pyvenv.cfg value"
200
+ if ($pyvenvCfg -and $pyvenvCfg['prompt']) {
201
+ Write-Verbose " Setting based on value in pyvenv.cfg='$($pyvenvCfg['prompt'])'"
202
+ $Prompt = $pyvenvCfg['prompt'];
203
+ }
204
+ else {
205
+ Write-Verbose " Setting prompt based on parent's directory's name. (Is the directory name passed to venv module when creating the virtual environment)"
206
+ Write-Verbose " Got leaf-name of $VenvDir='$(Split-Path -Path $venvDir -Leaf)'"
207
+ $Prompt = Split-Path -Path $venvDir -Leaf
208
+ }
209
+ }
210
+
211
+ Write-Verbose "Prompt = '$Prompt'"
212
+ Write-Verbose "VenvDir='$VenvDir'"
213
+
214
+ # Deactivate any currently active virtual environment, but leave the
215
+ # deactivate function in place.
216
+ deactivate -nondestructive
217
+
218
+ # Now set the environment variable VIRTUAL_ENV, used by many tools to determine
219
+ # that there is an activated venv.
220
+ $env:VIRTUAL_ENV = $VenvDir
221
+
222
+ if (-not $Env:VIRTUAL_ENV_DISABLE_PROMPT) {
223
+
224
+ Write-Verbose "Setting prompt to '$Prompt'"
225
+
226
+ # Set the prompt to include the env name
227
+ # Make sure _OLD_VIRTUAL_PROMPT is global
228
+ function global:_OLD_VIRTUAL_PROMPT { "" }
229
+ Copy-Item -Path function:prompt -Destination function:_OLD_VIRTUAL_PROMPT
230
+ New-Variable -Name _PYTHON_VENV_PROMPT_PREFIX -Description "Python virtual environment prompt prefix" -Scope Global -Option ReadOnly -Visibility Public -Value $Prompt
231
+
232
+ function global:prompt {
233
+ Write-Host -NoNewline -ForegroundColor Green "($_PYTHON_VENV_PROMPT_PREFIX) "
234
+ _OLD_VIRTUAL_PROMPT
235
+ }
236
+ $env:VIRTUAL_ENV_PROMPT = $Prompt
237
+ }
238
+
239
+ # Clear PYTHONHOME
240
+ if (Test-Path -Path Env:PYTHONHOME) {
241
+ Copy-Item -Path Env:PYTHONHOME -Destination Env:_OLD_VIRTUAL_PYTHONHOME
242
+ Remove-Item -Path Env:PYTHONHOME
243
+ }
244
+
245
+ # Add the venv to the PATH
246
+ Copy-Item -Path Env:PATH -Destination Env:_OLD_VIRTUAL_PATH
247
+ $Env:PATH = "$VenvExecDir$([System.IO.Path]::PathSeparator)$Env:PATH"
myenv/bin/activate ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate" *from bash*
2
+ # you cannot run it directly
3
+
4
+ deactivate () {
5
+ # reset old environment variables
6
+ if [ -n "${_OLD_VIRTUAL_PATH:-}" ] ; then
7
+ PATH="${_OLD_VIRTUAL_PATH:-}"
8
+ export PATH
9
+ unset _OLD_VIRTUAL_PATH
10
+ fi
11
+ if [ -n "${_OLD_VIRTUAL_PYTHONHOME:-}" ] ; then
12
+ PYTHONHOME="${_OLD_VIRTUAL_PYTHONHOME:-}"
13
+ export PYTHONHOME
14
+ unset _OLD_VIRTUAL_PYTHONHOME
15
+ fi
16
+
17
+ # This should detect bash and zsh, which have a hash command that must
18
+ # be called to get it to forget past commands. Without forgetting
19
+ # past commands the $PATH changes we made may not be respected
20
+ if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
21
+ hash -r 2> /dev/null
22
+ fi
23
+
24
+ if [ -n "${_OLD_VIRTUAL_PS1:-}" ] ; then
25
+ PS1="${_OLD_VIRTUAL_PS1:-}"
26
+ export PS1
27
+ unset _OLD_VIRTUAL_PS1
28
+ fi
29
+
30
+ unset VIRTUAL_ENV
31
+ unset VIRTUAL_ENV_PROMPT
32
+ if [ ! "${1:-}" = "nondestructive" ] ; then
33
+ # Self destruct!
34
+ unset -f deactivate
35
+ fi
36
+ }
37
+
38
+ # unset irrelevant variables
39
+ deactivate nondestructive
40
+
41
+ VIRTUAL_ENV="/root/editor-app-v10/myenv"
42
+ export VIRTUAL_ENV
43
+
44
+ _OLD_VIRTUAL_PATH="$PATH"
45
+ PATH="$VIRTUAL_ENV/bin:$PATH"
46
+ export PATH
47
+
48
+ # unset PYTHONHOME if set
49
+ # this will fail if PYTHONHOME is set to the empty string (which is bad anyway)
50
+ # could use `if (set -u; : $PYTHONHOME) ;` in bash
51
+ if [ -n "${PYTHONHOME:-}" ] ; then
52
+ _OLD_VIRTUAL_PYTHONHOME="${PYTHONHOME:-}"
53
+ unset PYTHONHOME
54
+ fi
55
+
56
+ if [ -z "${VIRTUAL_ENV_DISABLE_PROMPT:-}" ] ; then
57
+ _OLD_VIRTUAL_PS1="${PS1:-}"
58
+ PS1="(myenv) ${PS1:-}"
59
+ export PS1
60
+ VIRTUAL_ENV_PROMPT="(myenv) "
61
+ export VIRTUAL_ENV_PROMPT
62
+ fi
63
+
64
+ # This should detect bash and zsh, which have a hash command that must
65
+ # be called to get it to forget past commands. Without forgetting
66
+ # past commands the $PATH changes we made may not be respected
67
+ if [ -n "${BASH:-}" -o -n "${ZSH_VERSION:-}" ] ; then
68
+ hash -r 2> /dev/null
69
+ fi
myenv/bin/activate.csh ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source bin/activate.csh" *from csh*.
2
+ # You cannot run it directly.
3
+ # Created by Davide Di Blasi <davidedb@gmail.com>.
4
+ # Ported to Python 3.3 venv by Andrew Svetlov <andrew.svetlov@gmail.com>
5
+
6
+ alias deactivate 'test $?_OLD_VIRTUAL_PATH != 0 && setenv PATH "$_OLD_VIRTUAL_PATH" && unset _OLD_VIRTUAL_PATH; rehash; test $?_OLD_VIRTUAL_PROMPT != 0 && set prompt="$_OLD_VIRTUAL_PROMPT" && unset _OLD_VIRTUAL_PROMPT; unsetenv VIRTUAL_ENV; unsetenv VIRTUAL_ENV_PROMPT; test "\!:*" != "nondestructive" && unalias deactivate'
7
+
8
+ # Unset irrelevant variables.
9
+ deactivate nondestructive
10
+
11
+ setenv VIRTUAL_ENV "/root/editor-app-v10/myenv"
12
+
13
+ set _OLD_VIRTUAL_PATH="$PATH"
14
+ setenv PATH "$VIRTUAL_ENV/bin:$PATH"
15
+
16
+
17
+ set _OLD_VIRTUAL_PROMPT="$prompt"
18
+
19
+ if (! "$?VIRTUAL_ENV_DISABLE_PROMPT") then
20
+ set prompt = "(myenv) $prompt"
21
+ setenv VIRTUAL_ENV_PROMPT "(myenv) "
22
+ endif
23
+
24
+ alias pydoc python -m pydoc
25
+
26
+ rehash
myenv/bin/activate.fish ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # This file must be used with "source <venv>/bin/activate.fish" *from fish*
2
+ # (https://fishshell.com/); you cannot run it directly.
3
+
4
+ function deactivate -d "Exit virtual environment and return to normal shell environment"
5
+ # reset old environment variables
6
+ if test -n "$_OLD_VIRTUAL_PATH"
7
+ set -gx PATH $_OLD_VIRTUAL_PATH
8
+ set -e _OLD_VIRTUAL_PATH
9
+ end
10
+ if test -n "$_OLD_VIRTUAL_PYTHONHOME"
11
+ set -gx PYTHONHOME $_OLD_VIRTUAL_PYTHONHOME
12
+ set -e _OLD_VIRTUAL_PYTHONHOME
13
+ end
14
+
15
+ if test -n "$_OLD_FISH_PROMPT_OVERRIDE"
16
+ set -e _OLD_FISH_PROMPT_OVERRIDE
17
+ # prevents error when using nested fish instances (Issue #93858)
18
+ if functions -q _old_fish_prompt
19
+ functions -e fish_prompt
20
+ functions -c _old_fish_prompt fish_prompt
21
+ functions -e _old_fish_prompt
22
+ end
23
+ end
24
+
25
+ set -e VIRTUAL_ENV
26
+ set -e VIRTUAL_ENV_PROMPT
27
+ if test "$argv[1]" != "nondestructive"
28
+ # Self-destruct!
29
+ functions -e deactivate
30
+ end
31
+ end
32
+
33
+ # Unset irrelevant variables.
34
+ deactivate nondestructive
35
+
36
+ set -gx VIRTUAL_ENV "/root/editor-app-v10/myenv"
37
+
38
+ set -gx _OLD_VIRTUAL_PATH $PATH
39
+ set -gx PATH "$VIRTUAL_ENV/bin" $PATH
40
+
41
+ # Unset PYTHONHOME if set.
42
+ if set -q PYTHONHOME
43
+ set -gx _OLD_VIRTUAL_PYTHONHOME $PYTHONHOME
44
+ set -e PYTHONHOME
45
+ end
46
+
47
+ if test -z "$VIRTUAL_ENV_DISABLE_PROMPT"
48
+ # fish uses a function instead of an env var to generate the prompt.
49
+
50
+ # Save the current fish_prompt function as the function _old_fish_prompt.
51
+ functions -c fish_prompt _old_fish_prompt
52
+
53
+ # With the original prompt function renamed, we can override with our own.
54
+ function fish_prompt
55
+ # Save the return status of the last command.
56
+ set -l old_status $status
57
+
58
+ # Output the venv prompt; color taken from the blue of the Python logo.
59
+ printf "%s%s%s" (set_color 4B8BBE) "(myenv) " (set_color normal)
60
+
61
+ # Restore the return status of the previous command.
62
+ echo "exit $old_status" | .
63
+ # Output the original/"old" prompt.
64
+ _old_fish_prompt
65
+ end
66
+
67
+ set -gx _OLD_FISH_PROMPT_OVERRIDE "$VIRTUAL_ENV"
68
+ set -gx VIRTUAL_ENV_PROMPT "(myenv) "
69
+ end
myenv/bin/distro ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from distro.distro import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
myenv/bin/dotenv ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from dotenv.__main__ import cli
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli())
myenv/bin/email_validator ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from email_validator.__main__ import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
myenv/bin/f2py ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from numpy.f2py.f2py2e import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
myenv/bin/fastapi ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fastapi_cli.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
myenv/bin/fonttools ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from fontTools.__main__ import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
myenv/bin/gradio ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from gradio.cli import cli
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(cli())
myenv/bin/httpx ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from httpx import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
myenv/bin/huggingface-cli ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from huggingface_hub.commands.huggingface_cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
myenv/bin/jsondiff ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ from __future__ import print_function
5
+
6
+ import sys
7
+ import json
8
+ import jsonpatch
9
+ import argparse
10
+
11
+
12
+ parser = argparse.ArgumentParser(description='Diff two JSON files')
13
+ parser.add_argument('FILE1', type=argparse.FileType('r'))
14
+ parser.add_argument('FILE2', type=argparse.FileType('r'))
15
+ parser.add_argument('--indent', type=int, default=None,
16
+ help='Indent output by n spaces')
17
+ parser.add_argument('-u', '--preserve-unicode', action='store_true',
18
+ help='Output Unicode character as-is without using Code Point')
19
+ parser.add_argument('-v', '--version', action='version',
20
+ version='%(prog)s ' + jsonpatch.__version__)
21
+
22
+
23
+ def main():
24
+ try:
25
+ diff_files()
26
+ except KeyboardInterrupt:
27
+ sys.exit(1)
28
+
29
+
30
+ def diff_files():
31
+ """ Diffs two JSON files and prints a patch """
32
+ args = parser.parse_args()
33
+ doc1 = json.load(args.FILE1)
34
+ doc2 = json.load(args.FILE2)
35
+ patch = jsonpatch.make_patch(doc1, doc2)
36
+ if patch.patch:
37
+ print(json.dumps(patch.patch, indent=args.indent, ensure_ascii=not(args.preserve_unicode)))
38
+ sys.exit(1)
39
+
40
+ if __name__ == "__main__":
41
+ main()
myenv/bin/jsonpatch ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+ import sys
5
+ import os.path
6
+ import json
7
+ import jsonpatch
8
+ import tempfile
9
+ import argparse
10
+
11
+
12
+ parser = argparse.ArgumentParser(
13
+ description='Apply a JSON patch on a JSON file')
14
+ parser.add_argument('ORIGINAL', type=argparse.FileType('r'),
15
+ help='Original file')
16
+ parser.add_argument('PATCH', type=argparse.FileType('r'),
17
+ nargs='?', default=sys.stdin,
18
+ help='Patch file (read from stdin if omitted)')
19
+ parser.add_argument('--indent', type=int, default=None,
20
+ help='Indent output by n spaces')
21
+ parser.add_argument('-b', '--backup', action='store_true',
22
+ help='Back up ORIGINAL if modifying in-place')
23
+ parser.add_argument('-i', '--in-place', action='store_true',
24
+ help='Modify ORIGINAL in-place instead of to stdout')
25
+ parser.add_argument('-v', '--version', action='version',
26
+ version='%(prog)s ' + jsonpatch.__version__)
27
+ parser.add_argument('-u', '--preserve-unicode', action='store_true',
28
+ help='Output Unicode character as-is without using Code Point')
29
+
30
+ def main():
31
+ try:
32
+ patch_files()
33
+ except KeyboardInterrupt:
34
+ sys.exit(1)
35
+
36
+
37
+ def patch_files():
38
+ """ Diffs two JSON files and prints a patch """
39
+ args = parser.parse_args()
40
+ doc = json.load(args.ORIGINAL)
41
+ patch = json.load(args.PATCH)
42
+ result = jsonpatch.apply_patch(doc, patch)
43
+
44
+ if args.in_place:
45
+ dirname = os.path.abspath(os.path.dirname(args.ORIGINAL.name))
46
+
47
+ try:
48
+ # Attempt to replace the file atomically. We do this by
49
+ # creating a temporary file in the same directory as the
50
+ # original file so we can atomically move the new file over
51
+ # the original later. (This is done in the same directory
52
+ # because atomic renames do not work across mount points.)
53
+
54
+ fd, pathname = tempfile.mkstemp(dir=dirname)
55
+ fp = os.fdopen(fd, 'w')
56
+ atomic = True
57
+
58
+ except OSError:
59
+ # We failed to create the temporary file for an atomic
60
+ # replace, so fall back to non-atomic mode by backing up
61
+ # the original (if desired) and writing a new file.
62
+
63
+ if args.backup:
64
+ os.rename(args.ORIGINAL.name, args.ORIGINAL.name + '.orig')
65
+ fp = open(args.ORIGINAL.name, 'w')
66
+ atomic = False
67
+
68
+ else:
69
+ # Since we're not replacing the original file in-place, write
70
+ # the modified JSON to stdout instead.
71
+
72
+ fp = sys.stdout
73
+
74
+ # By this point we have some sort of file object we can write the
75
+ # modified JSON to.
76
+
77
+ json.dump(result, fp, indent=args.indent, ensure_ascii=not(args.preserve_unicode))
78
+ fp.write('\n')
79
+
80
+ if args.in_place:
81
+ # Close the new file. If we aren't replacing atomically, this
82
+ # is our last step, since everything else is already in place.
83
+
84
+ fp.close()
85
+
86
+ if atomic:
87
+ try:
88
+ # Complete the atomic replace by linking the original
89
+ # to a backup (if desired), fixing up the permissions
90
+ # on the temporary file, and moving it into place.
91
+
92
+ if args.backup:
93
+ os.link(args.ORIGINAL.name, args.ORIGINAL.name + '.orig')
94
+ os.chmod(pathname, os.stat(args.ORIGINAL.name).st_mode)
95
+ os.rename(pathname, args.ORIGINAL.name)
96
+
97
+ except OSError:
98
+ # In the event we could not actually do the atomic
99
+ # replace, unlink the original to move it out of the
100
+ # way and finally move the temporary file into place.
101
+
102
+ os.unlink(args.ORIGINAL.name)
103
+ os.rename(pathname, args.ORIGINAL.name)
104
+
105
+
106
+ if __name__ == "__main__":
107
+ main()
myenv/bin/jsonpointer ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+
4
+
5
+ import argparse
6
+ import json
7
+ import sys
8
+
9
+ import jsonpointer
10
+
11
+ parser = argparse.ArgumentParser(
12
+ description='Resolve a JSON pointer on JSON files')
13
+
14
+ # Accept pointer as argument or as file
15
+ ptr_group = parser.add_mutually_exclusive_group(required=True)
16
+
17
+ ptr_group.add_argument('-f', '--pointer-file', type=argparse.FileType('r'),
18
+ nargs='?',
19
+ help='File containing a JSON pointer expression')
20
+
21
+ ptr_group.add_argument('POINTER', type=str, nargs='?',
22
+ help='A JSON pointer expression')
23
+
24
+ parser.add_argument('FILE', type=argparse.FileType('r'), nargs='+',
25
+ help='Files for which the pointer should be resolved')
26
+ parser.add_argument('--indent', type=int, default=None,
27
+ help='Indent output by n spaces')
28
+ parser.add_argument('-v', '--version', action='version',
29
+ version='%(prog)s ' + jsonpointer.__version__)
30
+
31
+
32
+ def main():
33
+ try:
34
+ resolve_files()
35
+ except KeyboardInterrupt:
36
+ sys.exit(1)
37
+
38
+
39
+ def parse_pointer(args):
40
+ if args.POINTER:
41
+ ptr = args.POINTER
42
+ elif args.pointer_file:
43
+ ptr = args.pointer_file.read().strip()
44
+ else:
45
+ parser.print_usage()
46
+ sys.exit(1)
47
+
48
+ return ptr
49
+
50
+
51
+ def resolve_files():
52
+ """ Resolve a JSON pointer on JSON files """
53
+ args = parser.parse_args()
54
+
55
+ ptr = parse_pointer(args)
56
+
57
+ for f in args.FILE:
58
+ doc = json.load(f)
59
+ try:
60
+ result = jsonpointer.resolve_pointer(doc, ptr)
61
+ print(json.dumps(result, indent=args.indent))
62
+ except jsonpointer.JsonPointerException as e:
63
+ print('Could not resolve pointer: %s' % str(e), file=sys.stderr)
64
+
65
+
66
+ if __name__ == "__main__":
67
+ main()
myenv/bin/jsonschema ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from jsonschema.cli import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())
myenv/bin/langsmith ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ #!/root/editor-app-v10/myenv/bin/python3
2
+ # -*- coding: utf-8 -*-
3
+ import re
4
+ import sys
5
+ from langsmith.cli.main import main
6
+ if __name__ == '__main__':
7
+ sys.argv[0] = re.sub(r'(-script\.pyw|\.exe)?$', '', sys.argv[0])
8
+ sys.exit(main())