deepfos 1.0.54__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (162) hide show
  1. deepfos-1.0.54/MANIFEST.in +4 -0
  2. deepfos-1.0.54/PKG-INFO +19 -0
  3. deepfos-1.0.54/README.md +38 -0
  4. deepfos-1.0.54/deepfos/__init__.py +5 -0
  5. deepfos-1.0.54/deepfos/_version.py +623 -0
  6. deepfos-1.0.54/deepfos/api/V1_1/__init__.py +0 -0
  7. deepfos-1.0.54/deepfos/api/V1_1/business_model.py +119 -0
  8. deepfos-1.0.54/deepfos/api/V1_1/dimension.py +599 -0
  9. deepfos-1.0.54/deepfos/api/V1_1/models/__init__.py +0 -0
  10. deepfos-1.0.54/deepfos/api/V1_1/models/business_model.py +1033 -0
  11. deepfos-1.0.54/deepfos/api/V1_1/models/dimension.py +2463 -0
  12. deepfos-1.0.54/deepfos/api/V1_2/__init__.py +0 -0
  13. deepfos-1.0.54/deepfos/api/V1_2/dimension.py +250 -0
  14. deepfos-1.0.54/deepfos/api/V1_2/models/__init__.py +0 -0
  15. deepfos-1.0.54/deepfos/api/V1_2/models/dimension.py +2840 -0
  16. deepfos-1.0.54/deepfos/api/__init__.py +0 -0
  17. deepfos-1.0.54/deepfos/api/account.py +148 -0
  18. deepfos-1.0.54/deepfos/api/accounting_engines.py +147 -0
  19. deepfos-1.0.54/deepfos/api/app.py +626 -0
  20. deepfos-1.0.54/deepfos/api/approval_process.py +198 -0
  21. deepfos-1.0.54/deepfos/api/base.py +971 -0
  22. deepfos-1.0.54/deepfos/api/business_model.py +160 -0
  23. deepfos-1.0.54/deepfos/api/consolidation.py +129 -0
  24. deepfos-1.0.54/deepfos/api/datatable.py +329 -0
  25. deepfos-1.0.54/deepfos/api/deepfos_task.py +92 -0
  26. deepfos-1.0.54/deepfos/api/dimension.py +486 -0
  27. deepfos-1.0.54/deepfos/api/financial_model.py +311 -0
  28. deepfos-1.0.54/deepfos/api/journal_template.py +132 -0
  29. deepfos-1.0.54/deepfos/api/memory_financial_model.py +98 -0
  30. deepfos-1.0.54/deepfos/api/models/__init__.py +3 -0
  31. deepfos-1.0.54/deepfos/api/models/account.py +440 -0
  32. deepfos-1.0.54/deepfos/api/models/accounting_engines.py +756 -0
  33. deepfos-1.0.54/deepfos/api/models/app.py +1338 -0
  34. deepfos-1.0.54/deepfos/api/models/approval_process.py +1043 -0
  35. deepfos-1.0.54/deepfos/api/models/base.py +234 -0
  36. deepfos-1.0.54/deepfos/api/models/business_model.py +805 -0
  37. deepfos-1.0.54/deepfos/api/models/consolidation.py +711 -0
  38. deepfos-1.0.54/deepfos/api/models/datatable_mysql.py +427 -0
  39. deepfos-1.0.54/deepfos/api/models/deepfos_task.py +386 -0
  40. deepfos-1.0.54/deepfos/api/models/dimension.py +1393 -0
  41. deepfos-1.0.54/deepfos/api/models/financial_model.py +1790 -0
  42. deepfos-1.0.54/deepfos/api/models/journal_template.py +854 -0
  43. deepfos-1.0.54/deepfos/api/models/memory_financial_model.py +478 -0
  44. deepfos-1.0.54/deepfos/api/models/platform.py +178 -0
  45. deepfos-1.0.54/deepfos/api/models/python.py +221 -0
  46. deepfos-1.0.54/deepfos/api/models/reconciliation_engine.py +411 -0
  47. deepfos-1.0.54/deepfos/api/models/reconciliation_report.py +161 -0
  48. deepfos-1.0.54/deepfos/api/models/role_strategy.py +884 -0
  49. deepfos-1.0.54/deepfos/api/models/smartlist.py +237 -0
  50. deepfos-1.0.54/deepfos/api/models/space.py +1137 -0
  51. deepfos-1.0.54/deepfos/api/models/system.py +530 -0
  52. deepfos-1.0.54/deepfos/api/models/variable.py +463 -0
  53. deepfos-1.0.54/deepfos/api/models/workflow.py +946 -0
  54. deepfos-1.0.54/deepfos/api/platform.py +199 -0
  55. deepfos-1.0.54/deepfos/api/python.py +84 -0
  56. deepfos-1.0.54/deepfos/api/reconciliation_engine.py +183 -0
  57. deepfos-1.0.54/deepfos/api/reconciliation_report.py +64 -0
  58. deepfos-1.0.54/deepfos/api/role_strategy.py +234 -0
  59. deepfos-1.0.54/deepfos/api/smartlist.py +69 -0
  60. deepfos-1.0.54/deepfos/api/space.py +582 -0
  61. deepfos-1.0.54/deepfos/api/system.py +209 -0
  62. deepfos-1.0.54/deepfos/api/variable.py +154 -0
  63. deepfos-1.0.54/deepfos/api/workflow.py +264 -0
  64. deepfos-1.0.54/deepfos/boost/__init__.py +6 -0
  65. deepfos-1.0.54/deepfos/boost/jstream.c +4223 -0
  66. deepfos-1.0.54/deepfos/boost/jstream.pyx +92 -0
  67. deepfos-1.0.54/deepfos/boost/pandas.c +3819 -0
  68. deepfos-1.0.54/deepfos/boost/pandas.pyx +30 -0
  69. deepfos-1.0.54/deepfos/boost/py_jstream.py +89 -0
  70. deepfos-1.0.54/deepfos/boost/py_pandas.py +20 -0
  71. deepfos-1.0.54/deepfos/config.py +6 -0
  72. deepfos-1.0.54/deepfos/core/__init__.py +27 -0
  73. deepfos-1.0.54/deepfos/core/cube/__init__.py +10 -0
  74. deepfos-1.0.54/deepfos/core/cube/_base.py +462 -0
  75. deepfos-1.0.54/deepfos/core/cube/constants.py +21 -0
  76. deepfos-1.0.54/deepfos/core/cube/cube.py +408 -0
  77. deepfos-1.0.54/deepfos/core/cube/formula.py +707 -0
  78. deepfos-1.0.54/deepfos/core/cube/syscube.py +529 -0
  79. deepfos-1.0.54/deepfos/core/cube/typing.py +7 -0
  80. deepfos-1.0.54/deepfos/core/cube/utils.py +238 -0
  81. deepfos-1.0.54/deepfos/core/dimension/__init__.py +11 -0
  82. deepfos-1.0.54/deepfos/core/dimension/_base.py +508 -0
  83. deepfos-1.0.54/deepfos/core/dimension/dimcreator.py +185 -0
  84. deepfos-1.0.54/deepfos/core/dimension/dimension.py +469 -0
  85. deepfos-1.0.54/deepfos/core/dimension/dimexpr.py +271 -0
  86. deepfos-1.0.54/deepfos/core/dimension/dimmember.py +155 -0
  87. deepfos-1.0.54/deepfos/core/dimension/eledimension.py +24 -0
  88. deepfos-1.0.54/deepfos/core/dimension/filters.py +99 -0
  89. deepfos-1.0.54/deepfos/core/dimension/sysdimension.py +168 -0
  90. deepfos-1.0.54/deepfos/core/logictable/__init__.py +5 -0
  91. deepfos-1.0.54/deepfos/core/logictable/_cache.py +141 -0
  92. deepfos-1.0.54/deepfos/core/logictable/_operator.py +663 -0
  93. deepfos-1.0.54/deepfos/core/logictable/nodemixin.py +667 -0
  94. deepfos-1.0.54/deepfos/core/logictable/sqlcondition.py +595 -0
  95. deepfos-1.0.54/deepfos/core/logictable/tablemodel.py +485 -0
  96. deepfos-1.0.54/deepfos/db/__init__.py +50 -0
  97. deepfos-1.0.54/deepfos/db/cipher.py +660 -0
  98. deepfos-1.0.54/deepfos/db/clickhouse.py +189 -0
  99. deepfos-1.0.54/deepfos/db/connector.py +179 -0
  100. deepfos-1.0.54/deepfos/db/daclickhouse.py +171 -0
  101. deepfos-1.0.54/deepfos/db/dameng.py +87 -0
  102. deepfos-1.0.54/deepfos/db/damysql.py +189 -0
  103. deepfos-1.0.54/deepfos/db/dbkits.py +382 -0
  104. deepfos-1.0.54/deepfos/db/deepengine.py +99 -0
  105. deepfos-1.0.54/deepfos/db/gauss.py +83 -0
  106. deepfos-1.0.54/deepfos/db/kingbase.py +82 -0
  107. deepfos-1.0.54/deepfos/db/mysql.py +181 -0
  108. deepfos-1.0.54/deepfos/db/oracle.py +131 -0
  109. deepfos-1.0.54/deepfos/db/postgresql.py +185 -0
  110. deepfos-1.0.54/deepfos/db/sqlserver.py +99 -0
  111. deepfos-1.0.54/deepfos/db/utils.py +135 -0
  112. deepfos-1.0.54/deepfos/element/__init__.py +84 -0
  113. deepfos-1.0.54/deepfos/element/accounting.py +312 -0
  114. deepfos-1.0.54/deepfos/element/apvlprocess.py +167 -0
  115. deepfos-1.0.54/deepfos/element/base.py +387 -0
  116. deepfos-1.0.54/deepfos/element/bizmodel.py +1161 -0
  117. deepfos-1.0.54/deepfos/element/datatable.py +1914 -0
  118. deepfos-1.0.54/deepfos/element/dimension.py +842 -0
  119. deepfos-1.0.54/deepfos/element/fact_table.py +410 -0
  120. deepfos-1.0.54/deepfos/element/finmodel.py +1016 -0
  121. deepfos-1.0.54/deepfos/element/journal_template.py +852 -0
  122. deepfos-1.0.54/deepfos/element/pyscript.py +373 -0
  123. deepfos-1.0.54/deepfos/element/reconciliation.py +451 -0
  124. deepfos-1.0.54/deepfos/element/rolestrategy.py +213 -0
  125. deepfos-1.0.54/deepfos/element/smartlist.py +453 -0
  126. deepfos-1.0.54/deepfos/element/variable.py +747 -0
  127. deepfos-1.0.54/deepfos/element/workflow.py +444 -0
  128. deepfos-1.0.54/deepfos/exceptions/__init__.py +127 -0
  129. deepfos-1.0.54/deepfos/lazy_import.py +84 -0
  130. deepfos-1.0.54/deepfos/lib/__init__.py +0 -0
  131. deepfos-1.0.54/deepfos/lib/_javaobj.py +367 -0
  132. deepfos-1.0.54/deepfos/lib/asynchronous.py +711 -0
  133. deepfos-1.0.54/deepfos/lib/concurrency.py +80 -0
  134. deepfos-1.0.54/deepfos/lib/constant.py +30 -0
  135. deepfos-1.0.54/deepfos/lib/decorator.py +207 -0
  136. deepfos-1.0.54/deepfos/lib/deepchart.py +778 -0
  137. deepfos-1.0.54/deepfos/lib/deepux.py +203 -0
  138. deepfos-1.0.54/deepfos/lib/discovery.py +206 -0
  139. deepfos-1.0.54/deepfos/lib/eureka.py +138 -0
  140. deepfos-1.0.54/deepfos/lib/filterparser.py +751 -0
  141. deepfos-1.0.54/deepfos/lib/httpcli.py +103 -0
  142. deepfos-1.0.54/deepfos/lib/jsonstreamer.py +85 -0
  143. deepfos-1.0.54/deepfos/lib/nacos.py +225 -0
  144. deepfos-1.0.54/deepfos/lib/patch.py +92 -0
  145. deepfos-1.0.54/deepfos/lib/redis.py +234 -0
  146. deepfos-1.0.54/deepfos/lib/stopwatch.py +99 -0
  147. deepfos-1.0.54/deepfos/lib/subtask.py +571 -0
  148. deepfos-1.0.54/deepfos/lib/sysutils.py +661 -0
  149. deepfos-1.0.54/deepfos/lib/utils.py +940 -0
  150. deepfos-1.0.54/deepfos/local.py +160 -0
  151. deepfos-1.0.54/deepfos/options.py +613 -0
  152. deepfos-1.0.54/deepfos/translation.py +225 -0
  153. deepfos-1.0.54/deepfos.egg-info/PKG-INFO +19 -0
  154. deepfos-1.0.54/deepfos.egg-info/SOURCES.txt +162 -0
  155. deepfos-1.0.54/deepfos.egg-info/dependency_links.txt +1 -0
  156. deepfos-1.0.54/deepfos.egg-info/not-zip-safe +1 -0
  157. deepfos-1.0.54/deepfos.egg-info/requires.txt +14 -0
  158. deepfos-1.0.54/deepfos.egg-info/top_level.txt +1 -0
  159. deepfos-1.0.54/setup.cfg +53 -0
  160. deepfos-1.0.54/setup.py +58 -0
  161. deepfos-1.0.54/tests/__init__.py +0 -0
  162. deepfos-1.0.54/versioneer.py +2064 -0
@@ -0,0 +1,4 @@
1
+ include versioneer.py
2
+ include deepfos/_version.py
3
+ include *.pyi
4
+ recursive-include deepfos/boost *.pyx
@@ -0,0 +1,19 @@
1
+ Metadata-Version: 2.1
2
+ Name: deepfos
3
+ Version: 1.0.54
4
+ Summary: Collecions of useful and handy tools for deepfos platform
5
+ Home-page: http://py.deepfos.com
6
+ Author: deepfos-python-team
7
+ Author-email: wei.wei@proinnova.com.cn
8
+ License: UNKNOWN
9
+ Platform: UNKNOWN
10
+ Classifier: Development Status :: 3 - Alpha
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
13
+ Classifier: Programming Language :: Python :: 3.8
14
+ Classifier: Programming Language :: Python :: 3.9
15
+ Classifier: Programming Language :: Python :: 3.10
16
+ Requires-Python: >=3.8.3
17
+
18
+ UNKNOWN
19
+
@@ -0,0 +1,38 @@
1
+ <!-- # README -->
2
+ <p align="center">
3
+ <img src="./docs/source/images/Deepfos-white.png" width="30%"/><br/>
4
+ </p>
5
+ <h1 align="center">
6
+ DeepFOS SDK for Python
7
+ </h1>
8
+
9
+ ## 🌏 国际化
10
+
11
+ [简体中文](README.md) | [English](README.en.md)
12
+
13
+ ## ℹ️ 项目介绍
14
+
15
+ 此项目是DeepFOS平台的Python SDK,集成了平台Open API,以及平台中各种元素的封装。
16
+
17
+ ### 📖 文档
18
+
19
+ [DeepFOS 文档](http://py.deepfos.com)
20
+
21
+
22
+ ## ✳️ 功能特色
23
+
24
+ - todo
25
+
26
+
27
+ ## 💎 新手入门
28
+
29
+
30
+ ## 🤔 如何贡献
31
+
32
+
33
+ ## 🌟 贡献者
34
+ [@陈熙](https://e.gitee.com/proinnova/members/trend/axisarsae)
35
+ [@陈思聪](https://e.gitee.com/proinnova/members/trend/proinnova_sicong_chen)
36
+ [@杨璟](https://e.gitee.com/proinnova/members/trend/jyang-0506)
37
+ [@李扬](https://e.gitee.com/proinnova/members/trend/ryan_li1384)
38
+ [@陈文雍](https://e.gitee.com/proinnova/members/trend/calvinstk)
@@ -0,0 +1,5 @@
1
+ # from .core import *
2
+ from .options import OPTION, set_option, show_option
3
+
4
+ from . import _version
5
+ __version__ = _version.get_versions()['version']
@@ -0,0 +1,623 @@
1
+
2
+ # This file helps to compute a version number in source trees obtained from
3
+ # git-archive tarball (such as those provided by githubs download-from-tag
4
+ # feature). Distribution tarballs (built by setup.py sdist) and build
5
+ # directories (produced by setup.py build) will contain a much shorter file
6
+ # that just contains the computed version number.
7
+
8
+ # This file is released into the public domain. Generated by
9
+ # versioneer-0.20 (https://github.com/python-versioneer/python-versioneer)
10
+
11
+ """Git implementation of _version.py."""
12
+
13
+ import errno
14
+ import os
15
+ import re
16
+ import subprocess
17
+ import sys
18
+
19
+
20
+ def get_keywords():
21
+ """Get the keywords needed to look up the version information."""
22
+ # these strings will be replaced by git during git-archive.
23
+ # setup.py/versioneer.py will grep for the variable names, so they must
24
+ # each be defined on a line of their own. _version.py will just call
25
+ # get_keywords().
26
+ git_refnames = "$Format:%d$"
27
+ git_full = "$Format:%H$"
28
+ git_date = "$Format:%ci$"
29
+ keywords = {"refnames": git_refnames, "full": git_full, "date": git_date}
30
+ return keywords
31
+
32
+
33
+ class VersioneerConfig: # pylint: disable=too-few-public-methods
34
+ """Container for Versioneer configuration parameters."""
35
+
36
+
37
+ def get_config():
38
+ """Create, populate and return the VersioneerConfig() object."""
39
+ # these strings are filled in when 'setup.py versioneer' creates
40
+ # _version.py
41
+ cfg = VersioneerConfig()
42
+ cfg.VCS = "git"
43
+ cfg.style = "pep440"
44
+ cfg.tag_prefix = "v"
45
+ cfg.parentdir_prefix = "deepfos-"
46
+ cfg.versionfile_source = "deepfos/_version.py"
47
+ cfg.verbose = False
48
+ return cfg
49
+
50
+
51
+ class NotThisMethod(Exception):
52
+ """Exception raised if a method is not valid for the current scenario."""
53
+
54
+
55
+ LONG_VERSION_PY = {}
56
+ HANDLERS = {}
57
+
58
+
59
+ def register_vcs_handler(vcs, method): # decorator
60
+ """Create decorator to mark a method as the handler of a VCS."""
61
+ def decorate(f):
62
+ """Store f in HANDLERS[vcs][method]."""
63
+ if vcs not in HANDLERS:
64
+ HANDLERS[vcs] = {}
65
+ HANDLERS[vcs][method] = f
66
+ return f
67
+ return decorate
68
+
69
+
70
+ # pylint:disable=too-many-arguments,consider-using-with # noqa
71
+ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False,
72
+ env=None):
73
+ """Call the given command(s)."""
74
+ assert isinstance(commands, list)
75
+ process = None
76
+ for command in commands:
77
+ try:
78
+ dispcmd = str([command] + args)
79
+ # remember shell=False, so use git.cmd on windows, not just git
80
+ process = subprocess.Popen([command] + args, cwd=cwd, env=env,
81
+ stdout=subprocess.PIPE,
82
+ stderr=(subprocess.PIPE if hide_stderr
83
+ else None))
84
+ break
85
+ except EnvironmentError:
86
+ e = sys.exc_info()[1]
87
+ if e.errno == errno.ENOENT:
88
+ continue
89
+ if verbose:
90
+ print("unable to run %s" % dispcmd)
91
+ print(e)
92
+ return None, None
93
+ else:
94
+ if verbose:
95
+ print("unable to find command, tried %s" % (commands,))
96
+ return None, None
97
+ stdout = process.communicate()[0].strip().decode()
98
+ if process.returncode != 0:
99
+ if verbose:
100
+ print("unable to run %s (error)" % dispcmd)
101
+ print("stdout was %s" % stdout)
102
+ return None, process.returncode
103
+ return stdout, process.returncode
104
+
105
+
106
+ def versions_from_parentdir(parentdir_prefix, root, verbose):
107
+ """Try to determine the version from the parent directory name.
108
+
109
+ Source tarballs conventionally unpack into a directory that includes both
110
+ the project name and a version string. We will also support searching up
111
+ two directory levels for an appropriately named parent directory
112
+ """
113
+ rootdirs = []
114
+
115
+ for _ in range(3):
116
+ dirname = os.path.basename(root)
117
+ if dirname.startswith(parentdir_prefix):
118
+ return {"version": dirname[len(parentdir_prefix):],
119
+ "full-revisionid": None,
120
+ "dirty": False, "error": None, "date": None}
121
+ rootdirs.append(root)
122
+ root = os.path.dirname(root) # up a level
123
+
124
+ if verbose:
125
+ print("Tried directories %s but none started with prefix %s" %
126
+ (str(rootdirs), parentdir_prefix))
127
+ raise NotThisMethod("rootdir doesn't start with parentdir_prefix")
128
+
129
+
130
+ @register_vcs_handler("git", "get_keywords")
131
+ def git_get_keywords(versionfile_abs):
132
+ """Extract version information from the given file."""
133
+ # the code embedded in _version.py can just fetch the value of these
134
+ # keywords. When used from setup.py, we don't want to import _version.py,
135
+ # so we do it with a regexp instead. This function is not used from
136
+ # _version.py.
137
+ keywords = {}
138
+ try:
139
+ with open(versionfile_abs, "r") as fobj:
140
+ for line in fobj:
141
+ if line.strip().startswith("git_refnames ="):
142
+ mo = re.search(r'=\s*"(.*)"', line)
143
+ if mo:
144
+ keywords["refnames"] = mo.group(1)
145
+ if line.strip().startswith("git_full ="):
146
+ mo = re.search(r'=\s*"(.*)"', line)
147
+ if mo:
148
+ keywords["full"] = mo.group(1)
149
+ if line.strip().startswith("git_date ="):
150
+ mo = re.search(r'=\s*"(.*)"', line)
151
+ if mo:
152
+ keywords["date"] = mo.group(1)
153
+ except EnvironmentError:
154
+ pass
155
+ return keywords
156
+
157
+
158
+ @register_vcs_handler("git", "keywords")
159
+ def git_versions_from_keywords(keywords, tag_prefix, verbose):
160
+ """Get version information from git keywords."""
161
+ if "refnames" not in keywords:
162
+ raise NotThisMethod("Short version file found")
163
+ date = keywords.get("date")
164
+ if date is not None:
165
+ # Use only the last line. Previous lines may contain GPG signature
166
+ # information.
167
+ date = date.splitlines()[-1]
168
+
169
+ # git-2.2.0 added "%cI", which expands to an ISO-8601 -compliant
170
+ # datestamp. However we prefer "%ci" (which expands to an "ISO-8601
171
+ # -like" string, which we must then edit to make compliant), because
172
+ # it's been around since git-1.5.3, and it's too difficult to
173
+ # discover which version we're using, or to work around using an
174
+ # older one.
175
+ date = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
176
+ refnames = keywords["refnames"].strip()
177
+ if refnames.startswith("$Format"):
178
+ if verbose:
179
+ print("keywords are unexpanded, not using")
180
+ raise NotThisMethod("unexpanded keywords, not a git-archive tarball")
181
+ refs = {r.strip() for r in refnames.strip("()").split(",")}
182
+ # starting in git-1.8.3, tags are listed as "tag: foo-1.0" instead of
183
+ # just "foo-1.0". If we see a "tag: " prefix, prefer those.
184
+ TAG = "tag: "
185
+ tags = {r[len(TAG):] for r in refs if r.startswith(TAG)}
186
+ if not tags:
187
+ # Either we're using git < 1.8.3, or there really are no tags. We use
188
+ # a heuristic: assume all version tags have a digit. The old git %d
189
+ # expansion behaves like git log --decorate=short and strips out the
190
+ # refs/heads/ and refs/tags/ prefixes that would let us distinguish
191
+ # between branches and tags. By ignoring refnames without digits, we
192
+ # filter out many common branch names like "release" and
193
+ # "stabilization", as well as "HEAD" and "master".
194
+ tags = {r for r in refs if re.search(r'\d', r)}
195
+ if verbose:
196
+ print("discarding '%s', no digits" % ",".join(refs - tags))
197
+ if verbose:
198
+ print("likely tags: %s" % ",".join(sorted(tags)))
199
+ for ref in sorted(tags):
200
+ # sorting will prefer e.g. "2.0" over "2.0rc1"
201
+ if ref.startswith(tag_prefix):
202
+ r = ref[len(tag_prefix):]
203
+ # Filter out refs that exactly match prefix or that don't start
204
+ # with a number once the prefix is stripped (mostly a concern
205
+ # when prefix is '')
206
+ if not re.match(r'\d', r):
207
+ continue
208
+ if verbose:
209
+ print("picking %s" % r)
210
+ return {"version": r,
211
+ "full-revisionid": keywords["full"].strip(),
212
+ "dirty": False, "error": None,
213
+ "date": date}
214
+ # no suitable tags, so version is "0+unknown", but full hex is still there
215
+ if verbose:
216
+ print("no suitable tags, using unknown + full revision id")
217
+ return {"version": "0+unknown",
218
+ "full-revisionid": keywords["full"].strip(),
219
+ "dirty": False, "error": "no suitable tags", "date": None}
220
+
221
+
222
+ @register_vcs_handler("git", "pieces_from_vcs")
223
+ def git_pieces_from_vcs(tag_prefix, root, verbose, runner=run_command):
224
+ """Get version from 'git describe' in the root of the source tree.
225
+
226
+ This only gets called if the git-archive 'subst' keywords were *not*
227
+ expanded, and _version.py hasn't already been rewritten with a short
228
+ version string, meaning we're inside a checked out source tree.
229
+ """
230
+ GITS = ["git"]
231
+ if sys.platform == "win32":
232
+ GITS = ["git.cmd", "git.exe"]
233
+
234
+ _, rc = runner(GITS, ["rev-parse", "--git-dir"], cwd=root,
235
+ hide_stderr=True)
236
+ if rc != 0:
237
+ if verbose:
238
+ print("Directory %s not under git control" % root)
239
+ raise NotThisMethod("'git rev-parse --git-dir' returned error")
240
+
241
+ # if there is a tag matching tag_prefix, this yields TAG-NUM-gHEX[-dirty]
242
+ # if there isn't one, this yields HEX[-dirty] (no NUM)
243
+ describe_out, rc = runner(GITS, ["describe", "--tags", "--dirty",
244
+ "--always", "--long",
245
+ "--match", "%s*" % tag_prefix],
246
+ cwd=root)
247
+ # --long was added in git-1.5.5
248
+ if describe_out is None:
249
+ raise NotThisMethod("'git describe' failed")
250
+ describe_out = describe_out.strip()
251
+ full_out, rc = runner(GITS, ["rev-parse", "HEAD"], cwd=root)
252
+ if full_out is None:
253
+ raise NotThisMethod("'git rev-parse' failed")
254
+ full_out = full_out.strip()
255
+
256
+ pieces = {}
257
+ pieces["long"] = full_out
258
+ pieces["short"] = full_out[:7] # maybe improved later
259
+ pieces["error"] = None
260
+
261
+ branch_name, rc = runner(GITS, ["rev-parse", "--abbrev-ref", "HEAD"],
262
+ cwd=root)
263
+ # --abbrev-ref was added in git-1.6.3
264
+ if rc != 0 or branch_name is None:
265
+ raise NotThisMethod("'git rev-parse --abbrev-ref' returned error")
266
+ branch_name = branch_name.strip()
267
+
268
+ if branch_name == "HEAD":
269
+ # If we aren't exactly on a branch, pick a branch which represents
270
+ # the current commit. If all else fails, we are on a branchless
271
+ # commit.
272
+ branches, rc = runner(GITS, ["branch", "--contains"], cwd=root)
273
+ # --contains was added in git-1.5.4
274
+ if rc != 0 or branches is None:
275
+ raise NotThisMethod("'git branch --contains' returned error")
276
+ branches = branches.split("\n")
277
+
278
+ # Remove the first line if we're running detached
279
+ if "(" in branches[0]:
280
+ branches.pop(0)
281
+
282
+ # Strip off the leading "* " from the list of branches.
283
+ branches = [branch[2:] for branch in branches]
284
+ if "master" in branches:
285
+ branch_name = "master"
286
+ elif not branches:
287
+ branch_name = None
288
+ else:
289
+ # Pick the first branch that is returned. Good or bad.
290
+ branch_name = branches[0]
291
+
292
+ pieces["branch"] = branch_name
293
+
294
+ # parse describe_out. It will be like TAG-NUM-gHEX[-dirty] or HEX[-dirty]
295
+ # TAG might have hyphens.
296
+ git_describe = describe_out
297
+
298
+ # look for -dirty suffix
299
+ dirty = git_describe.endswith("-dirty")
300
+ pieces["dirty"] = dirty
301
+ if dirty:
302
+ git_describe = git_describe[:git_describe.rindex("-dirty")]
303
+
304
+ # now we have TAG-NUM-gHEX or HEX
305
+
306
+ if "-" in git_describe:
307
+ # TAG-NUM-gHEX
308
+ mo = re.search(r'^(.+)-(\d+)-g([0-9a-f]+)$', git_describe)
309
+ if not mo:
310
+ # unparseable. Maybe git-describe is misbehaving?
311
+ pieces["error"] = ("unable to parse git-describe output: '%s'"
312
+ % describe_out)
313
+ return pieces
314
+
315
+ # tag
316
+ full_tag = mo.group(1)
317
+ if not full_tag.startswith(tag_prefix):
318
+ if verbose:
319
+ fmt = "tag '%s' doesn't start with prefix '%s'"
320
+ print(fmt % (full_tag, tag_prefix))
321
+ pieces["error"] = ("tag '%s' doesn't start with prefix '%s'"
322
+ % (full_tag, tag_prefix))
323
+ return pieces
324
+ pieces["closest-tag"] = full_tag[len(tag_prefix):]
325
+
326
+ # distance: number of commits since tag
327
+ pieces["distance"] = int(mo.group(2))
328
+
329
+ # commit: short hex revision ID
330
+ pieces["short"] = mo.group(3)
331
+
332
+ else:
333
+ # HEX: no tags
334
+ pieces["closest-tag"] = None
335
+ count_out, rc = runner(GITS, ["rev-list", "HEAD", "--count"], cwd=root)
336
+ pieces["distance"] = int(count_out) # total number of commits
337
+
338
+ # commit date: see ISO-8601 comment in git_versions_from_keywords()
339
+ date = runner(GITS, ["show", "-s", "--format=%ci", "HEAD"], cwd=root)[0].strip()
340
+ # Use only the last line. Previous lines may contain GPG signature
341
+ # information.
342
+ date = date.splitlines()[-1]
343
+ pieces["date"] = date.strip().replace(" ", "T", 1).replace(" ", "", 1)
344
+
345
+ return pieces
346
+
347
+
348
+ def plus_or_dot(pieces):
349
+ """Return a + if we don't already have one, else return a ."""
350
+ if "+" in pieces.get("closest-tag", ""):
351
+ return "."
352
+ return "+"
353
+
354
+
355
+ def render_pep440(pieces):
356
+ """Build up version string, with post-release "local version identifier".
357
+
358
+ Our goal: TAG[+DISTANCE.gHEX[.dirty]] . Note that if you
359
+ get a tagged build and then dirty it, you'll get TAG+0.gHEX.dirty
360
+
361
+ Exceptions:
362
+ 1: no tags. git_describe was just HEX. 0+untagged.DISTANCE.gHEX[.dirty]
363
+ """
364
+ if pieces["closest-tag"]:
365
+ rendered = pieces["closest-tag"]
366
+ if pieces["distance"] or pieces["dirty"]:
367
+ rendered += plus_or_dot(pieces)
368
+ rendered += "%d.g%s" % (pieces["distance"], pieces["short"])
369
+ if pieces["dirty"]:
370
+ rendered += ".dirty"
371
+ else:
372
+ # exception #1
373
+ rendered = "0+untagged.%d.g%s" % (pieces["distance"],
374
+ pieces["short"])
375
+ if pieces["dirty"]:
376
+ rendered += ".dirty"
377
+ return rendered
378
+
379
+
380
+ def render_pep440_branch(pieces):
381
+ """TAG[[.dev0]+DISTANCE.gHEX[.dirty]] .
382
+
383
+ The ".dev0" means not master branch. Note that .dev0 sorts backwards
384
+ (a feature branch will appear "older" than the master branch).
385
+
386
+ Exceptions:
387
+ 1: no tags. 0[.dev0]+untagged.DISTANCE.gHEX[.dirty]
388
+ """
389
+ if pieces["closest-tag"]:
390
+ rendered = pieces["closest-tag"]
391
+ if pieces["distance"] or pieces["dirty"]:
392
+ if pieces["branch"] != "master":
393
+ rendered += ".dev0"
394
+ rendered += plus_or_dot(pieces)
395
+ rendered += "%d.g%s" % (pieces["distance"], pieces["short"])
396
+ if pieces["dirty"]:
397
+ rendered += ".dirty"
398
+ else:
399
+ # exception #1
400
+ rendered = "0"
401
+ if pieces["branch"] != "master":
402
+ rendered += ".dev0"
403
+ rendered += "+untagged.%d.g%s" % (pieces["distance"],
404
+ pieces["short"])
405
+ if pieces["dirty"]:
406
+ rendered += ".dirty"
407
+ return rendered
408
+
409
+
410
+ def render_pep440_pre(pieces):
411
+ """TAG[.post0.devDISTANCE] -- No -dirty.
412
+
413
+ Exceptions:
414
+ 1: no tags. 0.post0.devDISTANCE
415
+ """
416
+ if pieces["closest-tag"]:
417
+ rendered = pieces["closest-tag"]
418
+ if pieces["distance"]:
419
+ rendered += ".post0.dev%d" % pieces["distance"]
420
+ else:
421
+ # exception #1
422
+ rendered = "0.post0.dev%d" % pieces["distance"]
423
+ return rendered
424
+
425
+
426
+ def render_pep440_post(pieces):
427
+ """TAG[.postDISTANCE[.dev0]+gHEX] .
428
+
429
+ The ".dev0" means dirty. Note that .dev0 sorts backwards
430
+ (a dirty tree will appear "older" than the corresponding clean one),
431
+ but you shouldn't be releasing software with -dirty anyways.
432
+
433
+ Exceptions:
434
+ 1: no tags. 0.postDISTANCE[.dev0]
435
+ """
436
+ if pieces["closest-tag"]:
437
+ rendered = pieces["closest-tag"]
438
+ if pieces["distance"] or pieces["dirty"]:
439
+ rendered += ".post%d" % pieces["distance"]
440
+ if pieces["dirty"]:
441
+ rendered += ".dev0"
442
+ rendered += plus_or_dot(pieces)
443
+ rendered += "g%s" % pieces["short"]
444
+ else:
445
+ # exception #1
446
+ rendered = "0.post%d" % pieces["distance"]
447
+ if pieces["dirty"]:
448
+ rendered += ".dev0"
449
+ rendered += "+g%s" % pieces["short"]
450
+ return rendered
451
+
452
+
453
+ def render_pep440_post_branch(pieces):
454
+ """TAG[.postDISTANCE[.dev0]+gHEX[.dirty]] .
455
+
456
+ The ".dev0" means not master branch.
457
+
458
+ Exceptions:
459
+ 1: no tags. 0.postDISTANCE[.dev0]+gHEX[.dirty]
460
+ """
461
+ if pieces["closest-tag"]:
462
+ rendered = pieces["closest-tag"]
463
+ if pieces["distance"] or pieces["dirty"]:
464
+ rendered += ".post%d" % pieces["distance"]
465
+ if pieces["branch"] != "master":
466
+ rendered += ".dev0"
467
+ rendered += plus_or_dot(pieces)
468
+ rendered += "g%s" % pieces["short"]
469
+ if pieces["dirty"]:
470
+ rendered += ".dirty"
471
+ else:
472
+ # exception #1
473
+ rendered = "0.post%d" % pieces["distance"]
474
+ if pieces["branch"] != "master":
475
+ rendered += ".dev0"
476
+ rendered += "+g%s" % pieces["short"]
477
+ if pieces["dirty"]:
478
+ rendered += ".dirty"
479
+ return rendered
480
+
481
+
482
+ def render_pep440_old(pieces):
483
+ """TAG[.postDISTANCE[.dev0]] .
484
+
485
+ The ".dev0" means dirty.
486
+
487
+ Exceptions:
488
+ 1: no tags. 0.postDISTANCE[.dev0]
489
+ """
490
+ if pieces["closest-tag"]:
491
+ rendered = pieces["closest-tag"]
492
+ if pieces["distance"] or pieces["dirty"]:
493
+ rendered += ".post%d" % pieces["distance"]
494
+ if pieces["dirty"]:
495
+ rendered += ".dev0"
496
+ else:
497
+ # exception #1
498
+ rendered = "0.post%d" % pieces["distance"]
499
+ if pieces["dirty"]:
500
+ rendered += ".dev0"
501
+ return rendered
502
+
503
+
504
+ def render_git_describe(pieces):
505
+ """TAG[-DISTANCE-gHEX][-dirty].
506
+
507
+ Like 'git describe --tags --dirty --always'.
508
+
509
+ Exceptions:
510
+ 1: no tags. HEX[-dirty] (note: no 'g' prefix)
511
+ """
512
+ if pieces["closest-tag"]:
513
+ rendered = pieces["closest-tag"]
514
+ if pieces["distance"]:
515
+ rendered += "-%d-g%s" % (pieces["distance"], pieces["short"])
516
+ else:
517
+ # exception #1
518
+ rendered = pieces["short"]
519
+ if pieces["dirty"]:
520
+ rendered += "-dirty"
521
+ return rendered
522
+
523
+
524
+ def render_git_describe_long(pieces):
525
+ """TAG-DISTANCE-gHEX[-dirty].
526
+
527
+ Like 'git describe --tags --dirty --always -long'.
528
+ The distance/hash is unconditional.
529
+
530
+ Exceptions:
531
+ 1: no tags. HEX[-dirty] (note: no 'g' prefix)
532
+ """
533
+ if pieces["closest-tag"]:
534
+ rendered = pieces["closest-tag"]
535
+ rendered += "-%d-g%s" % (pieces["distance"], pieces["short"])
536
+ else:
537
+ # exception #1
538
+ rendered = pieces["short"]
539
+ if pieces["dirty"]:
540
+ rendered += "-dirty"
541
+ return rendered
542
+
543
+
544
+ def render(pieces, style):
545
+ """Render the given version pieces into the requested style."""
546
+ if pieces["error"]:
547
+ return {"version": "unknown",
548
+ "full-revisionid": pieces.get("long"),
549
+ "dirty": None,
550
+ "error": pieces["error"],
551
+ "date": None}
552
+
553
+ if not style or style == "default":
554
+ style = "pep440" # the default
555
+
556
+ if style == "pep440":
557
+ rendered = render_pep440(pieces)
558
+ elif style == "pep440-branch":
559
+ rendered = render_pep440_branch(pieces)
560
+ elif style == "pep440-pre":
561
+ rendered = render_pep440_pre(pieces)
562
+ elif style == "pep440-post":
563
+ rendered = render_pep440_post(pieces)
564
+ elif style == "pep440-post-branch":
565
+ rendered = render_pep440_post_branch(pieces)
566
+ elif style == "pep440-old":
567
+ rendered = render_pep440_old(pieces)
568
+ elif style == "git-describe":
569
+ rendered = render_git_describe(pieces)
570
+ elif style == "git-describe-long":
571
+ rendered = render_git_describe_long(pieces)
572
+ else:
573
+ raise ValueError("unknown style '%s'" % style)
574
+
575
+ return {"version": rendered, "full-revisionid": pieces["long"],
576
+ "dirty": pieces["dirty"], "error": None,
577
+ "date": pieces.get("date")}
578
+
579
+
580
+ def get_versions():
581
+ """Get version information or return default if unable to do so."""
582
+ # I am in _version.py, which lives at ROOT/VERSIONFILE_SOURCE. If we have
583
+ # __file__, we can work backwards from there to the root. Some
584
+ # py2exe/bbfreeze/non-CPython implementations don't do __file__, in which
585
+ # case we can only use expanded keywords.
586
+
587
+ cfg = get_config()
588
+ verbose = cfg.verbose
589
+
590
+ try:
591
+ return git_versions_from_keywords(get_keywords(), cfg.tag_prefix,
592
+ verbose)
593
+ except NotThisMethod:
594
+ pass
595
+
596
+ try:
597
+ root = os.path.realpath(__file__)
598
+ # versionfile_source is the relative path from the top of the source
599
+ # tree (where the .git directory might live) to this file. Invert
600
+ # this to find the root from __file__.
601
+ for _ in cfg.versionfile_source.split('/'):
602
+ root = os.path.dirname(root)
603
+ except NameError:
604
+ return {"version": "0+unknown", "full-revisionid": None,
605
+ "dirty": None,
606
+ "error": "unable to find root of source tree",
607
+ "date": None}
608
+
609
+ try:
610
+ pieces = git_pieces_from_vcs(cfg.tag_prefix, root, verbose)
611
+ return render(pieces, cfg.style)
612
+ except NotThisMethod:
613
+ pass
614
+
615
+ try:
616
+ if cfg.parentdir_prefix:
617
+ return versions_from_parentdir(cfg.parentdir_prefix, root, verbose)
618
+ except NotThisMethod:
619
+ pass
620
+
621
+ return {"version": "0+unknown", "full-revisionid": None,
622
+ "dirty": None,
623
+ "error": "unable to compute version", "date": None}
File without changes