您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

301 行
7.9KB

  1. import json
  2. from typing import NamedTuple, Tuple, List, Sequence, Union, Optional, Mapping
  3. import sys
  4. import textwrap
  5. class Git(NamedTuple):
  6. url: str
  7. ref: str
  8. auto_lib: Optional[str] = None
  9. def to_dict(self) -> dict:
  10. d = {
  11. 'url': self.url,
  12. 'ref': self.ref,
  13. }
  14. if self.auto_lib:
  15. d['auto-lib'] = self.auto_lib
  16. return d
  17. RemoteInfo = Union[Git]
  18. class Version(NamedTuple):
  19. version: str
  20. remote: RemoteInfo
  21. depends: Mapping[str, str] = {}
  22. description: str = '(No description provided)'
  23. def to_dict(self) -> dict:
  24. ret: dict = {
  25. 'description': self.description,
  26. }
  27. ret['depends'] = self.depends
  28. if isinstance(self.remote, Git):
  29. ret['git'] = self.remote.to_dict()
  30. return ret
  31. class Package(NamedTuple):
  32. name: str
  33. versions: List[Version]
  34. def many_versions(name: str,
  35. versions: Sequence[str],
  36. *,
  37. tag_fmt: str = '{}',
  38. git_url: str,
  39. auto_lib: str = None,
  40. description='(No description was provided)') -> Package:
  41. return Package(name, [
  42. Version(
  43. ver,
  44. description='\n'.join(textwrap.wrap(description)),
  45. remote=Git(
  46. url=git_url, ref=tag_fmt.format(ver), auto_lib=auto_lib))
  47. for ver in versions
  48. ])
  49. packages = [
  50. many_versions(
  51. 'range-v3',
  52. (
  53. '0.5.0',
  54. '0.9.0',
  55. '0.9.1',
  56. '0.10.0',
  57. ),
  58. git_url='https://github.com/ericniebler/range-v3.git',
  59. auto_lib='range-v3/range-v3',
  60. description=
  61. 'Range library for C++14/17/20, basis for C++20\'s std::ranges',
  62. ),
  63. many_versions(
  64. 'nlohmann-json',
  65. (
  66. '3.0.0',
  67. '3.0.1',
  68. '3.1.0',
  69. '3.1.1',
  70. '3.1.2',
  71. '3.2.0',
  72. '3.3.0',
  73. '3.4.0',
  74. '3.5.0',
  75. '3.6.0',
  76. '3.6.1',
  77. '3.7.0',
  78. '3.7.1',
  79. '3.7.2',
  80. '3.7.3',
  81. ),
  82. git_url='https://github.com/vector-of-bool/json.git',
  83. tag_fmt='dds/{}',
  84. description='JSON for Modern C++',
  85. ),
  86. Package('ms-wil', [
  87. Version(
  88. '2020.03.16',
  89. description='The Windows Implementation Library',
  90. remote=Git('https://github.com/vector-of-bool/wil.git',
  91. 'dds/2020.03.16'))
  92. ]),
  93. many_versions(
  94. 'neo-sqlite3',
  95. (
  96. '0.1.0',
  97. '0.2.0',
  98. '0.2.1',
  99. '0.2.2',
  100. '0.2.3',
  101. ),
  102. description='A modern and low-level C++ SQLite API',
  103. git_url='https://github.com/vector-of-bool/neo-sqlite3.git',
  104. ),
  105. many_versions(
  106. 'neo-fun',
  107. (
  108. '0.1.0',
  109. '0.1.1',
  110. '0.2.0',
  111. '0.2.1',
  112. '0.3.0',
  113. '0.3.1',
  114. '0.3.2',
  115. ),
  116. description='Some library fundamentals that you might find useful',
  117. git_url='https://github.com/vector-of-bool/neo-fun.git',
  118. ),
  119. many_versions(
  120. 'neo-concepts',
  121. (
  122. '0.1.0',
  123. '0.2.0',
  124. '0.2.1',
  125. '0.2.2',
  126. '0.3.0',
  127. '0.3.1',
  128. '0.3.2',
  129. ),
  130. description=
  131. 'Minimal C++ concepts library. Contains many definitions from C++20.',
  132. git_url='https://github.com/vector-of-bool/neo-concepts.git',
  133. ),
  134. Package('semver', [
  135. Version(
  136. '0.2.1',
  137. description=
  138. 'A C++ library that implements Semantic Versioning parsing, emitting, '
  139. 'types, ordering, and operations. See https://semver.org/',
  140. remote=Git('https://github.com/vector-of-bool/semver.git',
  141. '0.2.1')),
  142. Version(
  143. '0.2.2',
  144. description=
  145. 'A C++ library that implements Semantic Versioning parsing, emitting, '
  146. 'types, ordering, and operations. See https://semver.org/',
  147. remote=Git('https://github.com/vector-of-bool/semver.git',
  148. '0.2.2')),
  149. ]),
  150. many_versions(
  151. 'pubgrub',
  152. (
  153. '0.1.2',
  154. '0.2.0',
  155. '0.2.1',
  156. ),
  157. description=
  158. 'A C++ implementation of the Pubgrub version solving algorithm',
  159. git_url='https://github.com/vector-of-bool/pubgrub.git',
  160. ),
  161. many_versions(
  162. 'vob-json5',
  163. ('0.1.5', ),
  164. description='A C++ implementation of a JSON5 parser',
  165. git_url='https://github.com/vector-of-bool/json5.git',
  166. ),
  167. Package('vob-semester', [
  168. Version(
  169. '0.1.0',
  170. description='A C++ library to process recursive dynamic data',
  171. remote=Git('https://github.com/vector-of-bool/semester.git',
  172. '0.1.0'),
  173. depends={
  174. 'neo-fun': '^0.1.0',
  175. 'neo-concepts': '^0.2.1',
  176. }),
  177. Version(
  178. '0.1.1',
  179. description='A C++ library to process recursive dynamic data',
  180. remote=Git('https://github.com/vector-of-bool/semester.git',
  181. '0.1.1'),
  182. depends={
  183. 'neo-fun': '^0.1.1',
  184. 'neo-concepts': '^0.2.2',
  185. }),
  186. Version(
  187. '0.2.0',
  188. description='A C++ library to process recursive dynamic data',
  189. remote=Git('https://github.com/vector-of-bool/semester.git',
  190. '0.2.0'),
  191. depends={
  192. 'neo-fun': '^0.3.2',
  193. 'neo-concepts': '^0.3.2',
  194. }),
  195. Version(
  196. '0.2.1',
  197. description='A C++ library to process recursive dynamic data',
  198. remote=Git('https://github.com/vector-of-bool/semester.git',
  199. '0.2.1'),
  200. depends={
  201. 'neo-fun': '^0.3.2',
  202. 'neo-concepts': '^0.3.2',
  203. }),
  204. ]),
  205. Package('ctre', [
  206. Version(
  207. '2.7.0',
  208. description=
  209. 'A compile-time PCRE (almost) compatible regular expression matcher',
  210. remote=Git(
  211. 'https://github.com/hanickadot/compile-time-regular-expressions.git',
  212. 'v2.7',
  213. auto_lib='hanickadot/ctre',
  214. ))
  215. ]),
  216. many_versions(
  217. 'spdlog',
  218. (
  219. '0.9.0',
  220. '0.10.0',
  221. '0.11.0',
  222. '0.12.0',
  223. '0.13.0',
  224. '0.14.0',
  225. '0.16.0',
  226. '0.16.1',
  227. '0.16.2',
  228. '0.17.0',
  229. '1.0.0',
  230. '1.1.0',
  231. '1.2.0',
  232. '1.2.1',
  233. '1.3.0',
  234. '1.3.1',
  235. '1.4.0',
  236. '1.4.1',
  237. '1.4.2',
  238. ),
  239. git_url='https://github.com/gabime/spdlog.git',
  240. tag_fmt='v{}',
  241. auto_lib='spdlog/spdlog',
  242. description='Fast C++ logging library',
  243. ),
  244. many_versions(
  245. 'fmt',
  246. (
  247. '0.8.0',
  248. '0.9.0',
  249. '0.10.0',
  250. '0.12.0',
  251. '1.0.0',
  252. '1.1.0',
  253. '2.0.0',
  254. '2.0.1',
  255. '2.1.0',
  256. '2.1.1',
  257. '3.0.0',
  258. '3.0.1',
  259. '3.0.2',
  260. '4.0.0',
  261. '4.1.0',
  262. '5.0.0',
  263. '5.1.0',
  264. '5.2.0',
  265. '5.2.1',
  266. '5.3.0',
  267. '6.0.0',
  268. '6.1.0',
  269. '6.1.1',
  270. '6.1.2',
  271. ),
  272. git_url='https://github.com/fmtlib/fmt.git',
  273. auto_lib='fmt/fmt',
  274. description='A modern formatting library : https://fmt.dev/',
  275. ),
  276. ]
  277. data = {
  278. 'version': 1,
  279. 'packages': {
  280. pkg.name: {ver.version: ver.to_dict()
  281. for ver in pkg.versions}
  282. for pkg in packages
  283. }
  284. }
  285. print(json.dumps(data, indent=2, sort_keys=True))