選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

233 行
5.7KB

  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. return {
  11. 'url': self.url,
  12. 'ref': self.ref,
  13. 'auto-lib': self.auto_lib,
  14. }
  15. RemoteInfo = Union[Git]
  16. class Version(NamedTuple):
  17. version: str
  18. remote: RemoteInfo
  19. depends: Mapping[str, str] = {}
  20. description: str = '(No description provided)'
  21. def to_dict(self) -> dict:
  22. ret: dict = {
  23. 'description': self.description,
  24. }
  25. ret['depends'] = {}
  26. if isinstance(self.remote, Git):
  27. ret['git'] = self.remote.to_dict()
  28. return ret
  29. class Package(NamedTuple):
  30. name: str
  31. versions: List[Version]
  32. def many_versions(name: str,
  33. versions: Sequence[str],
  34. *,
  35. tag_fmt: str = '{}',
  36. git_url: str,
  37. auto_lib: str = None,
  38. description='(No description was provided)') -> Package:
  39. return Package(name, [
  40. Version(
  41. ver,
  42. description='\n'.join(textwrap.wrap(description)),
  43. remote=Git(
  44. url=git_url, ref=tag_fmt.format(ver), auto_lib=auto_lib))
  45. for ver in versions
  46. ])
  47. packages = [
  48. many_versions(
  49. 'range-v3',
  50. (
  51. '0.5.0',
  52. '0.9.0',
  53. '0.9.1',
  54. '0.10.0',
  55. ),
  56. git_url='https://github.com/ericniebler/range-v3.git',
  57. auto_lib='range-v3/range-v3',
  58. description=
  59. 'Range library for C++14/17/20, basis for C++20\'s std::ranges',
  60. ),
  61. many_versions(
  62. 'nlohmann-json',
  63. (
  64. '3.0.0',
  65. '3.0.1',
  66. '3.1.0',
  67. '3.1.1',
  68. '3.1.2',
  69. '3.2.0',
  70. '3.3.0',
  71. '3.4.0',
  72. '3.5.0',
  73. '3.6.0',
  74. '3.6.1',
  75. '3.7.0',
  76. '3.7.1',
  77. '3.7.2',
  78. '3.7.3',
  79. ),
  80. git_url='https://github.com/vector-of-bool/json.git',
  81. tag_fmt='dds/{}',
  82. description='JSON for Modern C++',
  83. ),
  84. Package('ms-wil', [
  85. Version(
  86. '2019.11.10',
  87. description='The Windows Implementation Library',
  88. remote=Git('https://github.com/vector-of-bool/wil.git',
  89. 'dds/2019.11.10'))
  90. ]),
  91. many_versions(
  92. 'neo-sqlite3',
  93. (
  94. '0.1.0',
  95. '0.2.0',
  96. '0.2.1',
  97. '0.2.2',
  98. ),
  99. description='A modern and low-level C++ SQLite API',
  100. git_url='https://github.com/vector-of-bool/neo-sqlite3.git',
  101. ),
  102. Package('neo-fun', [
  103. Version(
  104. '0.1.0',
  105. description='Some library fundamentals that you might find useful',
  106. remote=Git('https://github.com/vector-of-bool/neo-fun.git',
  107. '0.1.0'))
  108. ]),
  109. many_versions(
  110. 'neo-concepts',
  111. (
  112. '0.1.0',
  113. '0.2.0',
  114. '0.2.1',
  115. ),
  116. description=
  117. 'Minimal C++ concepts library. Contains many definitions from C++20.',
  118. git_url='https://github.com/vector-of-bool/neo-concepts.git',
  119. ),
  120. Package('semver', [
  121. Version(
  122. '0.2.1',
  123. description=
  124. 'A C++ library that implements Semantic Versioning parsing, emitting, '
  125. 'types, ordering, and operations. See https://semver.org/',
  126. remote=Git('https://github.com/vector-of-bool/semver.git',
  127. '0.2.1'))
  128. ]),
  129. many_versions(
  130. 'pubgrub',
  131. (
  132. '0.1.2',
  133. '0.2.0',
  134. ),
  135. description=
  136. 'A C++ implementation of the Pubgrub version solving algorithm',
  137. git_url='https://github.com/vector-of-bool/pubgrub.git',
  138. ),
  139. many_versions(
  140. 'json5',
  141. (
  142. '0.1.0',
  143. '0.1.2',
  144. ),
  145. description='A C++ implementation of a JSON5 parser',
  146. git_url='https://github.com/vector-of-bool/json5.git',
  147. ),
  148. many_versions(
  149. 'spdlog',
  150. (
  151. '0.9.0',
  152. '0.10.0',
  153. '0.11.0',
  154. '0.12.0',
  155. '0.13.0',
  156. '0.14.0',
  157. '0.16.0',
  158. '0.16.1',
  159. '0.16.2',
  160. '0.17.0',
  161. '1.0.0',
  162. '1.1.0',
  163. '1.2.0',
  164. '1.2.1',
  165. '1.3.0',
  166. '1.3.1',
  167. '1.4.0',
  168. '1.4.1',
  169. '1.4.2',
  170. ),
  171. git_url='https://github.com/gabime/spdlog.git',
  172. tag_fmt='v{}',
  173. auto_lib='spdlog/spdlog',
  174. description='Fast C++ logging library',
  175. ),
  176. many_versions(
  177. 'fmt',
  178. (
  179. '0.8.0',
  180. '0.9.0',
  181. '0.10.0',
  182. '0.12.0',
  183. '1.0.0',
  184. '1.1.0',
  185. '2.0.0',
  186. '2.0.1',
  187. '2.1.0',
  188. '2.1.1',
  189. '3.0.0',
  190. '3.0.1',
  191. '3.0.2',
  192. '4.0.0',
  193. '4.1.0',
  194. '5.0.0',
  195. '5.1.0',
  196. '5.2.0',
  197. '5.2.1',
  198. '5.3.0',
  199. '6.0.0',
  200. '6.1.0',
  201. '6.1.1',
  202. '6.1.2',
  203. ),
  204. git_url='https://github.com/fmtlib/fmt.git',
  205. auto_lib='fmt/fmt',
  206. description='A modern formatting library : https://fmt.dev/',
  207. ),
  208. ]
  209. data = {
  210. 'version': 1,
  211. 'packages': {
  212. pkg.name: {ver.version: ver.to_dict()
  213. for ver in pkg.versions}
  214. for pkg in packages
  215. }
  216. }
  217. print(json.dumps(data, indent=2, sort_keys=True))