增加了util里的get_error_msg
This commit is contained in:
Generated
+74
-19
@@ -31,9 +31,21 @@
|
||||
</select>
|
||||
</component>
|
||||
<component name="ChangeListManager">
|
||||
<list default="true" id="81247df9-f070-428a-8ff8-85c1a06086e7" name="Default Changelist" comment="重构了app">
|
||||
<change afterPath="$PROJECT_DIR$/utils/get_error_msg.py" afterDir="false" />
|
||||
<list default="true" id="81247df9-f070-428a-8ff8-85c1a06086e7" name="Default Changelist" comment="增加了util里的get_error_msg">
|
||||
<change afterPath="$PROJECT_DIR$/ITShowPlatform/config.ini" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/ITShowPlatform/rule.gitignore" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/backports/configparser/__init__.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/backports/configparser/compat.py" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/configparser-5.2.0.dist-info/INSTALLER" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/configparser-5.2.0.dist-info/LICENSE" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/configparser-5.2.0.dist-info/METADATA" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/configparser-5.2.0.dist-info/RECORD" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/configparser-5.2.0.dist-info/REQUESTED" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/configparser-5.2.0.dist-info/WHEEL" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/configparser-5.2.0.dist-info/top_level.txt" afterDir="false" />
|
||||
<change afterPath="$PROJECT_DIR$/venv/Lib/site-packages/configparser.py" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||
<change beforePath="$PROJECT_DIR$/ITShowPlatform/settings.py" beforeDir="false" afterPath="$PROJECT_DIR$/ITShowPlatform/settings.py" afterDir="false" />
|
||||
</list>
|
||||
<option name="SHOW_DIALOG" value="false" />
|
||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||
@@ -78,14 +90,36 @@
|
||||
<property name="last_opened_file_path" value="$PROJECT_DIR$/Apps" />
|
||||
<property name="nodejs_package_manager_path" value="npm" />
|
||||
<property name="restartRequiresConfirmation" value="false" />
|
||||
<property name="settings.editor.selected.configurable" value="com.jetbrains.django.DjangoModulesConfigurable" />
|
||||
<property name="settings.editor.selected.configurable" value="com.jetbrains.python.configuration.PyActiveSdkModuleConfigurable" />
|
||||
</component>
|
||||
<component name="RecentsManager">
|
||||
<key name="MoveFile.RECENT_KEYS">
|
||||
<recent name="C:\Users\PBDELL\Desktop\Django\ITShowPlatform\Apps" />
|
||||
</key>
|
||||
</component>
|
||||
<component name="RunManager">
|
||||
<component name="RunManager" selected="Django Server.ITShowPlatform">
|
||||
<configuration name="settings" type="PythonConfigurationType" factoryName="Python" temporary="true" nameIsGenerated="true">
|
||||
<module name="ITShowPlatform" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
<option name="PARENT_ENVS" value="true" />
|
||||
<envs>
|
||||
<env name="PYTHONUNBUFFERED" value="1" />
|
||||
</envs>
|
||||
<option name="SDK_HOME" value="" />
|
||||
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/ITShowPlatform" />
|
||||
<option name="IS_MODULE_SDK" value="true" />
|
||||
<option name="ADD_CONTENT_ROOTS" value="true" />
|
||||
<option name="ADD_SOURCE_ROOTS" value="true" />
|
||||
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
|
||||
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/ITShowPlatform/settings.py" />
|
||||
<option name="PARAMETERS" value="" />
|
||||
<option name="SHOW_COMMAND_LINE" value="false" />
|
||||
<option name="EMULATE_TERMINAL" value="false" />
|
||||
<option name="MODULE_MODE" value="false" />
|
||||
<option name="REDIRECT_INPUT" value="false" />
|
||||
<option name="INPUT_FILE" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<configuration name="ITShowPlatform" type="Python.DjangoServer" factoryName="Django server">
|
||||
<module name="ITShowPlatform" />
|
||||
<option name="INTERPRETER_OPTIONS" value="" />
|
||||
@@ -133,6 +167,11 @@
|
||||
<option name="customRunCommand" value="" />
|
||||
<method v="2" />
|
||||
</configuration>
|
||||
<recent_temporary>
|
||||
<list>
|
||||
<item itemvalue="Python.settings" />
|
||||
</list>
|
||||
</recent_temporary>
|
||||
</component>
|
||||
<component name="SvnConfiguration">
|
||||
<configuration />
|
||||
@@ -153,7 +192,8 @@
|
||||
<workItem from="1650790774256" duration="451000" />
|
||||
<workItem from="1650903753930" duration="1368000" />
|
||||
<workItem from="1651065854470" duration="1813000" />
|
||||
<workItem from="1651738641048" duration="5717000" />
|
||||
<workItem from="1651738641048" duration="6482000" />
|
||||
<workItem from="1651751601855" duration="3860000" />
|
||||
</task>
|
||||
<task id="LOCAL-00001" summary="fix">
|
||||
<created>1650187914913</created>
|
||||
@@ -176,7 +216,14 @@
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1651746739401</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="4" />
|
||||
<task id="LOCAL-00004" summary="增加了util里的get_error_msg">
|
||||
<created>1651748255265</created>
|
||||
<option name="number" value="00004" />
|
||||
<option name="presentableId" value="LOCAL-00004" />
|
||||
<option name="project" value="LOCAL" />
|
||||
<updated>1651748255265</updated>
|
||||
</task>
|
||||
<option name="localTasksCounter" value="5" />
|
||||
<servers />
|
||||
</component>
|
||||
<component name="TypeScriptGeneratedFilesManager">
|
||||
@@ -211,7 +258,8 @@
|
||||
<MESSAGE value="fix" />
|
||||
<MESSAGE value="修改+合并前的提交" />
|
||||
<MESSAGE value="重构了app" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="重构了app" />
|
||||
<MESSAGE value="增加了util里的get_error_msg" />
|
||||
<option name="LAST_COMMIT_MESSAGE" value="增加了util里的get_error_msg" />
|
||||
</component>
|
||||
<component name="WindowStateProjectService">
|
||||
<state x="460" y="12" key="#ITShowPlatform" timestamp="1651644593580">
|
||||
@@ -226,6 +274,10 @@
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state x="223" y="87" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.0.1536.864@0.0.1536.864" timestamp="1651645077454" />
|
||||
<state x="489" y="228" key="#com.intellij.fileTypes.FileTypeChooser" timestamp="1651753494236">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state x="489" y="228" key="#com.intellij.fileTypes.FileTypeChooser/0.0.1536.864@0.0.1536.864" timestamp="1651753494236" />
|
||||
<state x="93" y="93" width="1350" height="678" key="DiffContextDialog" timestamp="1650785927137">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
@@ -242,22 +294,22 @@
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state x="615" y="342" key="Github.Dialog.Accounts.Choose/0.0.1536.864@0.0.1536.864" timestamp="1650187937570" />
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.bottom" timestamp="1651746397547">
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.bottom" timestamp="1651755221112">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.bottom/0.0.1536.864@0.0.1536.864" timestamp="1651746397546" />
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.center" timestamp="1651746397545">
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.bottom/0.0.1536.864@0.0.1536.864" timestamp="1651755221112" />
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.center" timestamp="1651755221111">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.center/0.0.1536.864@0.0.1536.864" timestamp="1651746397545" />
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.left" timestamp="1651746397545">
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.center/0.0.1536.864@0.0.1536.864" timestamp="1651755221111" />
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.left" timestamp="1651755221111">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.left/0.0.1536.864@0.0.1536.864" timestamp="1651746397545" />
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.right" timestamp="1651746397546">
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.left/0.0.1536.864@0.0.1536.864" timestamp="1651755221111" />
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.right" timestamp="1651755221112">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.right/0.0.1536.864@0.0.1536.864" timestamp="1651746397546" />
|
||||
<state width="1493" height="216" key="GridCell.Tab.0.right/0.0.1536.864@0.0.1536.864" timestamp="1651755221112" />
|
||||
<state width="1493" height="269" key="GridCell.Tab.1.bottom" timestamp="1651745777781">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
@@ -282,14 +334,14 @@
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state x="396" y="185" key="MultipleFileMergeDialog/0.0.1536.864@0.0.1536.864" timestamp="1650903868503" />
|
||||
<state x="270" y="76" key="SettingsEditor" timestamp="1651645101984">
|
||||
<state x="270" y="76" key="SettingsEditor" timestamp="1651753942877">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state x="270" y="76" key="SettingsEditor/0.0.1536.864@0.0.1536.864" timestamp="1651645101984" />
|
||||
<state x="361" y="161" key="Vcs.Push.Dialog.v2" timestamp="1651746748238">
|
||||
<state x="270" y="76" key="SettingsEditor/0.0.1536.864@0.0.1536.864" timestamp="1651753942877" />
|
||||
<state x="361" y="161" key="Vcs.Push.Dialog.v2" timestamp="1651748975959">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
<state x="361" y="161" key="Vcs.Push.Dialog.v2/0.0.1536.864@0.0.1536.864" timestamp="1651746748238" />
|
||||
<state x="361" y="161" key="Vcs.Push.Dialog.v2/0.0.1536.864@0.0.1536.864" timestamp="1651748975959" />
|
||||
<state x="93" y="93" width="1350" height="678" key="com.intellij.history.integration.ui.views.FileHistoryDialog" timestamp="1651645036813">
|
||||
<screen x="0" y="0" width="1536" height="864" />
|
||||
</state>
|
||||
@@ -307,4 +359,7 @@
|
||||
</state>
|
||||
<state x="520" y="210" key="git4idea.merge.GitMergeDialog/0.0.1536.864@0.0.1536.864" timestamp="1650785115917" />
|
||||
</component>
|
||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||
<SUITE FILE_PATH="coverage/ITShowPlatform$settings.coverage" NAME="settings Coverage Results" MODIFIED="1651755204349" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$/ITShowPlatform" />
|
||||
</component>
|
||||
</project>
|
||||
@@ -0,0 +1,3 @@
|
||||
config.ini
|
||||
|
||||
settings.py
|
||||
@@ -0,0 +1,22 @@
|
||||
[email]
|
||||
EMAIL_HOST = smtp.qq.com # 服务器
|
||||
|
||||
EMAIL_PORT = 465
|
||||
|
||||
EMAIL_HOST_USER = 2302253692@qq.com # 账号
|
||||
|
||||
EMAIL_HOST_PASSWORD = idujbpdlpgbmdhjg # 密码 (注意:这里的密码指的是授权码)
|
||||
|
||||
EMAIL_USE_SSL = True # 一般都为False
|
||||
|
||||
EMAIL_FROM = 2302253692@qq.com # 邮箱来自
|
||||
|
||||
[database]
|
||||
|
||||
ENGINE = django.db.backends.mysql
|
||||
|
||||
NAME = ITShowPlatform
|
||||
|
||||
USER = root
|
||||
|
||||
PASSWORD = HNXhnx123
|
||||
+18
-10
@@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/4.0/ref/settings/
|
||||
|
||||
from pathlib import Path
|
||||
import os
|
||||
import configparser
|
||||
|
||||
# Build paths inside the project like this: BASE_DIR / 'subdir'.
|
||||
BASE_DIR = Path(__file__).resolve().parent.parent
|
||||
@@ -29,6 +30,12 @@ ALLOWED_HOSTS = ["*"]
|
||||
|
||||
# Application definition
|
||||
|
||||
conf = configparser.ConfigParser()
|
||||
|
||||
conf.read(str(BASE_DIR)+r"\ITShowPlatform\config.ini",encoding="utf-8")
|
||||
|
||||
|
||||
|
||||
INSTALLED_APPS = [
|
||||
'django.contrib.admin',
|
||||
'django.contrib.auth',
|
||||
@@ -79,10 +86,10 @@ WSGI_APPLICATION = 'ITShowPlatform.wsgi.application'
|
||||
|
||||
DATABASES = {
|
||||
'default': {
|
||||
'ENGINE': 'django.db.backends.mysql',
|
||||
'NAME': 'ITShowPlatform',
|
||||
'USER': 'root',
|
||||
'PASSWORD': 'HNXhnx123',
|
||||
'ENGINE': conf.get("database","ENGINE"),
|
||||
'NAME': conf.get("database","NAME"),
|
||||
'USER': conf.get("database","USER"),
|
||||
'PASSWORD': conf.get("database","PASSWORD"),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,9 +145,10 @@ REST_FRAMEWORK = {
|
||||
)
|
||||
}
|
||||
|
||||
EMAIL_HOST = "smtp.qq.com" # 服务器
|
||||
EMAIL_PORT = 465
|
||||
EMAIL_HOST_USER = "2302253692@qq.com" # 账号
|
||||
EMAIL_HOST_PASSWORD = "idujbpdlpgbmdhjg" # 密码 (注意:这里的密码指的是授权码)
|
||||
EMAIL_USE_SSL = True # 一般都为False
|
||||
EMAIL_FROM = "2302253692@qq.com" # 邮箱来自
|
||||
EMAIL_HOST = conf.get('email',"EMAIL_HOST") # 服务器
|
||||
EMAIL_PORT = conf.get("email","EMAIL_PORT")
|
||||
EMAIL_HOST_USER = conf.get("email","EMAIL_HOST_USER") # 账号
|
||||
EMAIL_HOST_PASSWORD = conf.get("email","EMAIL_HOST_PASSWORD") # 密码 (注意:这里的密码指的是授权码)
|
||||
EMAIL_USE_SSL = conf.get("email","EMAIL_USE_SSL") # 一般都为False
|
||||
EMAIL_FROM = conf.get("email","EMAIL_FROM") # 邮箱来自
|
||||
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
import types
|
||||
import io as _io
|
||||
|
||||
|
||||
def text_encoding(encoding, stacklevel=2):
|
||||
"""
|
||||
Stubbed version of io.text_encoding as found in Python 3.10
|
||||
"""
|
||||
return encoding
|
||||
|
||||
|
||||
def copy_module(mod, **defaults):
|
||||
copy = types.ModuleType(mod.__name__, doc=mod.__doc__)
|
||||
vars(copy).update(defaults)
|
||||
vars(copy).update(vars(mod))
|
||||
return copy
|
||||
|
||||
|
||||
io = copy_module(_io, text_encoding=text_encoding)
|
||||
@@ -0,0 +1 @@
|
||||
pip
|
||||
@@ -0,0 +1,19 @@
|
||||
Copyright Jason R. Coombs
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to
|
||||
deal in the Software without restriction, including without limitation the
|
||||
rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
sell copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
||||
IN THE SOFTWARE.
|
||||
@@ -0,0 +1,267 @@
|
||||
Metadata-Version: 2.1
|
||||
Name: configparser
|
||||
Version: 5.2.0
|
||||
Summary: Updated configparser from Python 3.8 for Python 2.6+.
|
||||
Home-page: https://github.com/jaraco/configparser/
|
||||
Author: Łukasz Langa
|
||||
Author-email: lukasz@langa.pl
|
||||
Maintainer: Jason R. Coombs
|
||||
Maintainer-email: jaraco@jaraco.com
|
||||
License: UNKNOWN
|
||||
Keywords: configparser ini parsing conf cfg configuration file
|
||||
Platform: any
|
||||
Classifier: Development Status :: 5 - Production/Stable
|
||||
Classifier: Intended Audience :: Developers
|
||||
Classifier: License :: OSI Approved :: MIT License
|
||||
Classifier: Programming Language :: Python :: 3
|
||||
Classifier: Programming Language :: Python :: 3 :: Only
|
||||
Requires-Python: >=3.6
|
||||
License-File: LICENSE
|
||||
Provides-Extra: docs
|
||||
Requires-Dist: sphinx ; extra == 'docs'
|
||||
Requires-Dist: jaraco.packaging (>=8.2) ; extra == 'docs'
|
||||
Requires-Dist: rst.linker (>=1.9) ; extra == 'docs'
|
||||
Requires-Dist: jaraco.tidelift (>=1.4) ; extra == 'docs'
|
||||
Provides-Extra: testing
|
||||
Requires-Dist: pytest (>=6) ; extra == 'testing'
|
||||
Requires-Dist: pytest-checkdocs (>=2.4) ; extra == 'testing'
|
||||
Requires-Dist: pytest-flake8 ; extra == 'testing'
|
||||
Requires-Dist: pytest-cov ; extra == 'testing'
|
||||
Requires-Dist: pytest-enabler (>=1.0.1) ; extra == 'testing'
|
||||
Requires-Dist: types-backports ; extra == 'testing'
|
||||
Requires-Dist: pytest-black (>=0.3.7) ; (platform_python_implementation != "PyPy") and extra == 'testing'
|
||||
Requires-Dist: pytest-mypy ; (platform_python_implementation != "PyPy") and extra == 'testing'
|
||||
|
||||
.. image:: https://img.shields.io/pypi/v/configparser.svg
|
||||
:target: `PyPI link`_
|
||||
|
||||
.. image:: https://img.shields.io/pypi/pyversions/configparser.svg
|
||||
:target: `PyPI link`_
|
||||
|
||||
.. _PyPI link: https://pypi.org/project/configparser
|
||||
|
||||
.. image:: https://github.com/jaraco/configparser/workflows/tests/badge.svg
|
||||
:target: https://github.com/jaraco/configparser/actions?query=workflow%3A%22tests%22
|
||||
:alt: tests
|
||||
|
||||
.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
|
||||
:target: https://github.com/psf/black
|
||||
:alt: Code style: Black
|
||||
|
||||
.. image:: https://readthedocs.org/projects/configparser/badge/?version=latest
|
||||
:target: https://configparser.readthedocs.io/en/latest/?badge=latest
|
||||
|
||||
.. image:: https://img.shields.io/badge/skeleton-2021-informational
|
||||
:target: https://blog.jaraco.com/skeleton
|
||||
|
||||
.. image:: https://tidelift.com/badges/package/pypi/configparser
|
||||
:target: https://tidelift.com/subscription/pkg/pypi-configparser?utm_source=pypi-configparser&utm_medium=readme
|
||||
|
||||
|
||||
This package is a backport of the refreshed and enhanced ConfigParser from
|
||||
later Python versions. To use the backport instead of the built-in version,
|
||||
simply import it explicitly as a backport::
|
||||
|
||||
from backports import configparser
|
||||
|
||||
To use the backport on Python 2 and the built-in version on
|
||||
Python 3, use the standard invocation::
|
||||
|
||||
import configparser
|
||||
|
||||
For detailed documentation consult the vanilla version at
|
||||
http://docs.python.org/3/library/configparser.html.
|
||||
|
||||
Why you'll love ``configparser``
|
||||
--------------------------------
|
||||
|
||||
Whereas almost completely compatible with its older brother, ``configparser``
|
||||
sports a bunch of interesting new features:
|
||||
|
||||
* full mapping protocol access (`more info
|
||||
<http://docs.python.org/3/library/configparser.html#mapping-protocol-access>`_)::
|
||||
|
||||
>>> parser = ConfigParser()
|
||||
>>> parser.read_string("""
|
||||
[DEFAULT]
|
||||
location = upper left
|
||||
visible = yes
|
||||
editable = no
|
||||
color = blue
|
||||
|
||||
[main]
|
||||
title = Main Menu
|
||||
color = green
|
||||
|
||||
[options]
|
||||
title = Options
|
||||
""")
|
||||
>>> parser['main']['color']
|
||||
'green'
|
||||
>>> parser['main']['editable']
|
||||
'no'
|
||||
>>> section = parser['options']
|
||||
>>> section['title']
|
||||
'Options'
|
||||
>>> section['title'] = 'Options (editable: %(editable)s)'
|
||||
>>> section['title']
|
||||
'Options (editable: no)'
|
||||
|
||||
* there's now one default ``ConfigParser`` class, which basically is the old
|
||||
``SafeConfigParser`` with a bunch of tweaks which make it more predictable for
|
||||
users. Don't need interpolation? Simply use
|
||||
``ConfigParser(interpolation=None)``, no need to use a distinct
|
||||
``RawConfigParser`` anymore.
|
||||
|
||||
* the parser is highly `customizable upon instantiation
|
||||
<http://docs.python.org/3/library/configparser.html#customizing-parser-behaviour>`__
|
||||
supporting things like changing option delimiters, comment characters, the
|
||||
name of the DEFAULT section, the interpolation syntax, etc.
|
||||
|
||||
* you can easily create your own interpolation syntax but there are two powerful
|
||||
implementations built-in (`more info
|
||||
<http://docs.python.org/3/library/configparser.html#interpolation-of-values>`__):
|
||||
|
||||
* the classic ``%(string-like)s`` syntax (called ``BasicInterpolation``)
|
||||
|
||||
* a new ``${buildout:like}`` syntax (called ``ExtendedInterpolation``)
|
||||
|
||||
* fallback values may be specified in getters (`more info
|
||||
<http://docs.python.org/3/library/configparser.html#fallback-values>`__)::
|
||||
|
||||
>>> config.get('closet', 'monster',
|
||||
... fallback='No such things as monsters')
|
||||
'No such things as monsters'
|
||||
|
||||
* ``ConfigParser`` objects can now read data directly `from strings
|
||||
<http://docs.python.org/3/library/configparser.html#configparser.ConfigParser.read_string>`__
|
||||
and `from dictionaries
|
||||
<http://docs.python.org/3/library/configparser.html#configparser.ConfigParser.read_dict>`__.
|
||||
That means importing configuration from JSON or specifying default values for
|
||||
the whole configuration (multiple sections) is now a single line of code. Same
|
||||
goes for copying data from another ``ConfigParser`` instance, thanks to its
|
||||
mapping protocol support.
|
||||
|
||||
* many smaller tweaks, updates and fixes
|
||||
|
||||
A few words about Unicode
|
||||
-------------------------
|
||||
|
||||
``configparser`` comes from Python 3 and as such it works well with Unicode.
|
||||
The library is generally cleaned up in terms of internal data storage and
|
||||
reading/writing files. There are a couple of incompatibilities with the old
|
||||
``ConfigParser`` due to that. However, the work required to migrate is well
|
||||
worth it as it shows the issues that would likely come up during migration of
|
||||
your project to Python 3.
|
||||
|
||||
The design assumes that Unicode strings are used whenever possible [1]_. That
|
||||
gives you the certainty that what's stored in a configuration object is text.
|
||||
Once your configuration is read, the rest of your application doesn't have to
|
||||
deal with encoding issues. All you have is text [2]_. The only two phases when
|
||||
you should explicitly state encoding is when you either read from an external
|
||||
source (e.g. a file) or write back.
|
||||
|
||||
Versioning
|
||||
----------
|
||||
|
||||
This project uses `semver <https://semver.org/spec/v2.0.0.html>`_ to
|
||||
communicate the impact of various releases while periodically syncing
|
||||
with the upstream implementation in CPython.
|
||||
The `history <https://configparser.readthedocs.io/en/latest/history.html>`_
|
||||
serves as a reference indicating which versions incorporate
|
||||
which upstream functionality.
|
||||
|
||||
Prior to the ``4.0.0`` release, `another scheme
|
||||
<https://github.com/jaraco/configparser/blob/3.8.1/README.rst#versioning>`_
|
||||
was used to associate the CPython and backports releases.
|
||||
|
||||
Maintenance
|
||||
-----------
|
||||
|
||||
This backport was originally authored by Łukasz Langa, the current vanilla
|
||||
``configparser`` maintainer for CPython and is currently maintained by
|
||||
Jason R. Coombs:
|
||||
|
||||
* `configparser repository <https://github.com/jaraco/configparser>`_
|
||||
|
||||
* `configparser issue tracker <https://github.com/jaraco/configparser/issues>`_
|
||||
|
||||
For Enterprise
|
||||
==============
|
||||
|
||||
Available as part of the Tidelift Subscription.
|
||||
|
||||
This project and the maintainers of thousands of other packages are working with Tidelift to deliver one enterprise subscription that covers all of the open source you use.
|
||||
|
||||
`Learn more <https://tidelift.com/subscription/pkg/pypi-configparser?utm_source=pypi-configparser&utm_medium=referral&utm_campaign=github>`_.
|
||||
|
||||
Security Contact
|
||||
----------------
|
||||
|
||||
To report a security vulnerability, please use the
|
||||
`Tidelift security contact <https://tidelift.com/security>`_.
|
||||
Tidelift will coordinate the fix and disclosure.
|
||||
|
||||
Conversion Process
|
||||
------------------
|
||||
|
||||
This section is technical and should bother you only if you are wondering how
|
||||
this backport is produced. If the implementation details of this backport are
|
||||
not important for you, feel free to ignore the following content.
|
||||
|
||||
The project takes the following branching approach:
|
||||
|
||||
* The ``3.x`` branch holds unchanged files synchronized from the upstream
|
||||
CPython repository. The synchronization is currently done by manually copying
|
||||
the required files and stating from which CPython changeset they come.
|
||||
|
||||
* The ``main`` branch holds a version of the ``3.x`` code with some tweaks
|
||||
that make it compatible with older Pythons. Code on this branch must work
|
||||
on all supported Python versions. Test with ``tox`` or in CI.
|
||||
|
||||
The process works like this:
|
||||
|
||||
1. In the ``3.x`` branch, run ``pip-run -- sync-upstream.py``, which
|
||||
downloads the latest stable release of Python and copies the relevant
|
||||
files from there into their new locations and then commits those
|
||||
changes with a nice reference to the relevant upstream commit hash.
|
||||
|
||||
2. Check for new names in ``__all__`` and update imports in
|
||||
``configparser.py`` accordingly. Optionally, run the tests on a late
|
||||
Python 3. Commit.
|
||||
|
||||
3. Merge the new commit to ``main``. Run tests. Commit.
|
||||
|
||||
4. Make any compatibility changes on ``main``. Run tests. Commit.
|
||||
|
||||
5. Update the docs and release the new version.
|
||||
|
||||
|
||||
Footnotes
|
||||
---------
|
||||
|
||||
.. [1] To somewhat ease migration, passing bytestrings is still supported but
|
||||
they are converted to Unicode for internal storage anyway. This means
|
||||
that for the vast majority of strings used in configuration files, it
|
||||
won't matter if you pass them as bytestrings or Unicode. However, if you
|
||||
pass a bytestring that cannot be converted to Unicode using the naive
|
||||
ASCII codec, a ``UnicodeDecodeError`` will be raised. This is purposeful
|
||||
and helps you manage proper encoding for all content you store in
|
||||
memory, read from various sources and write back.
|
||||
|
||||
.. [2] Life gets much easier when you understand that you basically manage
|
||||
**text** in your application. You don't care about bytes but about
|
||||
letters. In that regard the concept of content encoding is meaningless.
|
||||
The only time when you deal with raw bytes is when you write the data to
|
||||
a file. Then you have to specify how your text should be encoded. On
|
||||
the other end, to get meaningful text from a file, the application
|
||||
reading it has to know which encoding was used during its creation. But
|
||||
once the bytes are read and properly decoded, all you have is text. This
|
||||
is especially powerful when you start interacting with multiple data
|
||||
sources. Even if each of them uses a different encoding, inside your
|
||||
application data is held in abstract text form. You can program your
|
||||
business logic without worrying about which data came from which source.
|
||||
You can freely exchange the data you store between sources. Only
|
||||
reading/writing files requires encoding your text to bytes.
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
__pycache__/configparser.cpython-39.pyc,,
|
||||
backports/configparser/__init__.py,sha256=zjgAe9lH7_cTCyt7e-iyfyi007PfaMAVPhJCjM_TUPs,54655
|
||||
backports/configparser/__pycache__/__init__.cpython-39.pyc,,
|
||||
backports/configparser/__pycache__/compat.cpython-39.pyc,,
|
||||
backports/configparser/compat.py,sha256=Z3Fo6AI4BfFRfNd9Fj8n1Yw2NW2r112uQTFEnF659Lc,404
|
||||
configparser-5.2.0.dist-info/INSTALLER,sha256=zuuue4knoyJ-UwPPXg8fezS7VCrXJQrAP7zeNuwvFQg,4
|
||||
configparser-5.2.0.dist-info/LICENSE,sha256=2z8CRrH5J48VhFuZ_sR4uLUG63ZIeZNyL4xuJUKF-vg,1050
|
||||
configparser-5.2.0.dist-info/METADATA,sha256=4MeDipErpJIH61Zwu6BQ9f951Qu5HRg5RKFu3LYNZck,11053
|
||||
configparser-5.2.0.dist-info/RECORD,,
|
||||
configparser-5.2.0.dist-info/REQUESTED,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
||||
configparser-5.2.0.dist-info/WHEEL,sha256=ewwEueio1C2XeHTvT17n8dZUJgOvyCWCt0WVNLClP9o,92
|
||||
configparser-5.2.0.dist-info/top_level.txt,sha256=mIs8gajd7cvEWhVluv4u6ocaHw_TJ9rOrpkZEFv-7Hc,23
|
||||
configparser.py,sha256=4VADEswCwzy_RDVgvje3BmZhD6iwo3k4EkUZcgzLD4M,1546
|
||||
@@ -0,0 +1,5 @@
|
||||
Wheel-Version: 1.0
|
||||
Generator: bdist_wheel (0.37.0)
|
||||
Root-Is-Purelib: true
|
||||
Tag: py3-none-any
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
backports
|
||||
configparser
|
||||
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
"""Convenience module importing everything from backports.configparser."""
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import division
|
||||
from __future__ import print_function
|
||||
from __future__ import unicode_literals
|
||||
|
||||
from backports.configparser import (
|
||||
RawConfigParser,
|
||||
ConfigParser,
|
||||
SafeConfigParser,
|
||||
SectionProxy,
|
||||
Interpolation,
|
||||
BasicInterpolation,
|
||||
ExtendedInterpolation,
|
||||
LegacyInterpolation,
|
||||
NoSectionError,
|
||||
DuplicateSectionError,
|
||||
DuplicateOptionError,
|
||||
NoOptionError,
|
||||
InterpolationError,
|
||||
InterpolationMissingOptionError,
|
||||
InterpolationSyntaxError,
|
||||
InterpolationDepthError,
|
||||
ParsingError,
|
||||
MissingSectionHeaderError,
|
||||
ConverterMapping,
|
||||
DEFAULTSECT,
|
||||
MAX_INTERPOLATION_DEPTH,
|
||||
)
|
||||
|
||||
from backports.configparser import Error, _UNSET, _default_dict, _ChainMap # noqa: F401
|
||||
|
||||
__all__ = [
|
||||
"NoSectionError",
|
||||
"DuplicateOptionError",
|
||||
"DuplicateSectionError",
|
||||
"NoOptionError",
|
||||
"InterpolationError",
|
||||
"InterpolationDepthError",
|
||||
"InterpolationMissingOptionError",
|
||||
"InterpolationSyntaxError",
|
||||
"ParsingError",
|
||||
"MissingSectionHeaderError",
|
||||
"ConfigParser",
|
||||
"SafeConfigParser",
|
||||
"RawConfigParser",
|
||||
"Interpolation",
|
||||
"BasicInterpolation",
|
||||
"ExtendedInterpolation",
|
||||
"LegacyInterpolation",
|
||||
"SectionProxy",
|
||||
"ConverterMapping",
|
||||
"DEFAULTSECT",
|
||||
"MAX_INTERPOLATION_DEPTH",
|
||||
]
|
||||
|
||||
# NOTE: names missing from __all__ imported anyway for backwards compatibility.
|
||||
Reference in New Issue
Block a user