grow 2.2.3__tar.gz → 2.3.0__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 (242) hide show
  1. {grow-2.2.3 → grow-2.3.0}/LICENSE +1 -1
  2. grow-2.3.0/MANIFEST.in +5 -0
  3. grow-2.3.0/PKG-INFO +135 -0
  4. grow-2.3.0/README.md +92 -0
  5. grow-2.3.0/grow/__init__.py +26 -0
  6. {grow-2.2.3 → grow-2.3.0}/grow/__main__.py +2 -1
  7. {grow-2.2.3 → grow-2.3.0}/grow/cache/collection_cache.py +16 -26
  8. {grow-2.2.3 → grow-2.3.0}/grow/cache/file_cache.py +1 -0
  9. {grow-2.2.3 → grow-2.3.0}/grow/cache/object_cache.py +0 -1
  10. {grow-2.2.3 → grow-2.3.0}/grow/cache/podcache.py +19 -31
  11. {grow-2.2.3 → grow-2.3.0}/grow/cache/routes_cache.py +4 -3
  12. grow-2.3.0/grow/cache/simple_cache.py +75 -0
  13. {grow-2.2.3 → grow-2.3.0}/grow/cli.py +2 -5
  14. {grow-2.2.3 → grow-2.3.0}/grow/collections/collection.py +84 -86
  15. {grow-2.2.3 → grow-2.3.0}/grow/collections/collection_routes.py +1 -0
  16. grow-2.3.0/grow/commands/__init__.py +16 -0
  17. {grow-2.2.3 → grow-2.3.0}/grow/commands/deprecated.py +4 -3
  18. grow-2.3.0/grow/commands/group.py +111 -0
  19. {grow-2.2.3 → grow-2.3.0}/grow/commands/shared.py +76 -42
  20. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/build.py +66 -22
  21. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/convert.py +6 -5
  22. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/deploy.py +59 -31
  23. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/inspect.py +2 -4
  24. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/inspect_routes.py +8 -6
  25. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/inspect_stats.py +12 -6
  26. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/inspect_untranslated.py +9 -5
  27. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/install.py +25 -17
  28. grow-2.3.0/grow/commands/subcommands/preprocess.py +61 -0
  29. grow-2.3.0/grow/commands/subcommands/run.py +80 -0
  30. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/stage.py +52 -32
  31. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/translations.py +9 -7
  32. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/translations_diff.py +3 -3
  33. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/translations_download.py +7 -4
  34. grow-2.3.0/grow/commands/subcommands/translations_extract.py +146 -0
  35. grow-2.3.0/grow/commands/subcommands/translations_filter.py +74 -0
  36. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/translations_import.py +22 -11
  37. grow-2.3.0/grow/commands/subcommands/translations_upload.py +123 -0
  38. {grow-2.2.3 → grow-2.3.0}/grow/common/base_config.py +2 -2
  39. {grow-2.2.3 → grow-2.3.0}/grow/common/bulk_errors.py +3 -1
  40. grow-2.3.0/grow/common/colors.py +20 -0
  41. {grow-2.2.3 → grow-2.3.0}/grow/common/deprecated.py +6 -8
  42. {grow-2.2.3 → grow-2.3.0}/grow/common/features.py +1 -0
  43. {grow-2.2.3 → grow-2.3.0}/grow/common/json_encoder.py +2 -5
  44. {grow-2.2.3 → grow-2.3.0}/grow/common/logger.py +2 -0
  45. {grow-2.2.3 → grow-2.3.0}/grow/common/markdown_extensions.py +31 -36
  46. grow-2.3.0/grow/common/oauth.py +128 -0
  47. grow-2.3.0/grow/common/progressbar_non.py +97 -0
  48. {grow-2.2.3 → grow-2.3.0}/grow/common/rc_config.py +9 -11
  49. grow-2.3.0/grow/common/remap.py +62 -0
  50. {grow-2.2.3 → grow-2.3.0}/grow/common/structures.py +26 -25
  51. {grow-2.2.3 → grow-2.3.0}/grow/common/subprocesses.py +1 -0
  52. grow-2.3.0/grow/common/tables.py +143 -0
  53. {grow-2.2.3 → grow-2.3.0}/grow/common/timer.py +2 -1
  54. {grow-2.2.3 → grow-2.3.0}/grow/common/untag.py +33 -25
  55. {grow-2.2.3 → grow-2.3.0}/grow/common/urls.py +9 -7
  56. {grow-2.2.3 → grow-2.3.0}/grow/common/utils.py +202 -136
  57. {grow-2.2.3 → grow-2.3.0}/grow/common/yaml_utils.py +15 -28
  58. grow-2.3.0/grow/conversion/__init__.py +1 -0
  59. {grow-2.2.3 → grow-2.3.0}/grow/conversion/collection_routing.py +29 -23
  60. {grow-2.2.3 → grow-2.3.0}/grow/conversion/content_locale_split.py +80 -80
  61. {grow-2.2.3 → grow-2.3.0}/grow/deployments/deployments.py +3 -2
  62. {grow-2.2.3 → grow-2.3.0}/grow/deployments/destinations/base.py +69 -52
  63. {grow-2.2.3 → grow-2.3.0}/grow/deployments/destinations/git_destination.py +16 -19
  64. {grow-2.2.3 → grow-2.3.0}/grow/deployments/destinations/local.py +7 -3
  65. {grow-2.2.3 → grow-2.3.0}/grow/deployments/destinations/webreview_destination.py +39 -20
  66. {grow-2.2.3 → grow-2.3.0}/grow/deployments/indexes.py +94 -84
  67. {grow-2.2.3 → grow-2.3.0}/grow/deployments/messages.py +1 -2
  68. {grow-2.2.3 → grow-2.3.0}/grow/deployments/stats.py +7 -6
  69. {grow-2.2.3 → grow-2.3.0}/grow/deployments/tests.py +6 -6
  70. {grow-2.2.3 → grow-2.3.0}/grow/deployments/utils.py +3 -5
  71. {grow-2.2.3 → grow-2.3.0}/grow/documents/document.py +77 -78
  72. {grow-2.2.3 → grow-2.3.0}/grow/documents/document_fields.py +4 -7
  73. {grow-2.2.3 → grow-2.3.0}/grow/documents/document_format.py +23 -27
  74. {grow-2.2.3 → grow-2.3.0}/grow/documents/document_front_matter.py +31 -24
  75. {grow-2.2.3 → grow-2.3.0}/grow/documents/static_document.py +31 -35
  76. grow-2.3.0/grow/extensions/__init__.py +6 -0
  77. {grow-2.2.3 → grow-2.3.0}/grow/extensions/base_extension.py +3 -5
  78. {grow-2.2.3 → grow-2.3.0}/grow/extensions/core/__init__.py +7 -5
  79. {grow-2.2.3 → grow-2.3.0}/grow/extensions/core/deployment_extension.py +3 -9
  80. {grow-2.2.3 → grow-2.3.0}/grow/extensions/core/node_extension.py +1 -4
  81. {grow-2.2.3 → grow-2.3.0}/grow/extensions/core/pod_extension.py +4 -6
  82. {grow-2.2.3 → grow-2.3.0}/grow/extensions/core/podcache_extension.py +5 -6
  83. {grow-2.2.3 → grow-2.3.0}/grow/extensions/core/routes_extension.py +80 -55
  84. {grow-2.2.3 → grow-2.3.0}/grow/extensions/extension_controller.py +9 -13
  85. {grow-2.2.3 → grow-2.3.0}/grow/extensions/extension_importer.py +12 -11
  86. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hook_controller.py +1 -2
  87. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/__init__.py +15 -14
  88. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/base_hook.py +0 -1
  89. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/deployment_register_hook.py +0 -1
  90. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/dev_file_change_hook.py +0 -1
  91. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/dev_handler_hook.py +0 -1
  92. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/dev_manager_message_hook.py +0 -1
  93. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/jinja_env_init_hook.py +0 -1
  94. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/jinja_extension_hook.py +0 -1
  95. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/podspec_static_dir_hook.py +0 -1
  96. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/post_render_hook.py +0 -1
  97. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/pre_deploy_hook.py +0 -1
  98. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/pre_process_hook.py +12 -14
  99. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/pre_render_hook.py +0 -1
  100. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/router_add_hook.py +0 -1
  101. {grow-2.2.3 → grow-2.3.0}/grow/extensions/hooks/stub_hook.py +0 -1
  102. {grow-2.2.3 → grow-2.3.0}/grow/partials/partial.py +7 -9
  103. {grow-2.2.3 → grow-2.3.0}/grow/partials/partials.py +6 -6
  104. {grow-2.2.3 → grow-2.3.0}/grow/performance/docs_loader.py +9 -16
  105. {grow-2.2.3 → grow-2.3.0}/grow/performance/profile.py +3 -4
  106. {grow-2.2.3 → grow-2.3.0}/grow/performance/profile_report.py +4 -4
  107. {grow-2.2.3 → grow-2.3.0}/grow/pods/dependency.py +9 -6
  108. {grow-2.2.3 → grow-2.3.0}/grow/pods/env.py +4 -7
  109. {grow-2.2.3 → grow-2.3.0}/grow/pods/errors.py +1 -2
  110. {grow-2.2.3 → grow-2.3.0}/grow/pods/footnotes.py +13 -13
  111. grow-2.3.0/grow/pods/importers.py +9 -0
  112. {grow-2.2.3 → grow-2.3.0}/grow/pods/messages.py +2 -0
  113. {grow-2.2.3 → grow-2.3.0}/grow/pods/pods.py +153 -173
  114. {grow-2.2.3 → grow-2.3.0}/grow/pods/podspec.py +2 -4
  115. {grow-2.2.3 → grow-2.3.0}/grow/pods/ui.py +5 -4
  116. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/base.py +2 -5
  117. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/blogger.py +33 -31
  118. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/file_watchers.py +25 -22
  119. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/google_drive.py +161 -125
  120. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/gulp.py +5 -4
  121. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/preprocessors.py +5 -7
  122. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/translation.py +2 -0
  123. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/webpack.py +5 -4
  124. {grow-2.2.3 → grow-2.3.0}/grow/rendering/markdown_utils.py +5 -5
  125. {grow-2.2.3 → grow-2.3.0}/grow/rendering/render_batch.py +40 -38
  126. {grow-2.2.3 → grow-2.3.0}/grow/rendering/render_controller.py +89 -98
  127. {grow-2.2.3 → grow-2.3.0}/grow/rendering/render_pool.py +9 -10
  128. {grow-2.2.3 → grow-2.3.0}/grow/rendering/rendered_document.py +4 -4
  129. {grow-2.2.3 → grow-2.3.0}/grow/rendering/renderer.py +9 -11
  130. {grow-2.2.3 → grow-2.3.0}/grow/routing/path_filter.py +3 -7
  131. {grow-2.2.3 → grow-2.3.0}/grow/routing/path_format.py +6 -7
  132. {grow-2.2.3 → grow-2.3.0}/grow/routing/router.py +170 -125
  133. {grow-2.2.3 → grow-2.3.0}/grow/routing/routes.py +41 -54
  134. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installer.py +7 -8
  135. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installers/__init__.py +8 -6
  136. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installers/base_installer.py +4 -6
  137. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installers/bower_installer.py +8 -8
  138. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installers/extensions_installer.py +10 -15
  139. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installers/gerrit_installer.py +8 -12
  140. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installers/gulp_installer.py +6 -5
  141. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installers/npm_installer.py +23 -24
  142. {grow-2.2.3 → grow-2.3.0}/grow/sdk/installers/nvm_installer.py +7 -9
  143. {grow-2.2.3 → grow-2.3.0}/grow/sdk/sdk_utils.py +0 -1
  144. {grow-2.2.3 → grow-2.3.0}/grow/server/handlers.py +25 -24
  145. {grow-2.2.3 → grow-2.3.0}/grow/server/main.py +42 -17
  146. {grow-2.2.3 → grow-2.3.0}/grow/server/manager.py +47 -37
  147. grow-2.3.0/grow/storage/__init__.py +8 -0
  148. {grow-2.2.3 → grow-2.3.0}/grow/storage/base_storage.py +0 -1
  149. {grow-2.2.3 → grow-2.3.0}/grow/storage/errors.py +1 -2
  150. {grow-2.2.3 → grow-2.3.0}/grow/storage/file_storage.py +11 -21
  151. {grow-2.2.3 → grow-2.3.0}/grow/templates/doc_dependency.py +0 -1
  152. {grow-2.2.3 → grow-2.3.0}/grow/templates/filters.py +26 -27
  153. {grow-2.2.3 → grow-2.3.0}/grow/templates/jinja_dependency.py +44 -26
  154. {grow-2.2.3 → grow-2.3.0}/grow/templates/jinja_loader.py +3 -3
  155. {grow-2.2.3 → grow-2.3.0}/grow/templates/tags.py +35 -32
  156. {grow-2.2.3 → grow-2.3.0}/grow/templates/tests.py +3 -0
  157. {grow-2.2.3 → grow-2.3.0}/grow/translations/catalog_holder.py +199 -152
  158. {grow-2.2.3 → grow-2.3.0}/grow/translations/catalogs.py +45 -46
  159. {grow-2.2.3 → grow-2.3.0}/grow/translations/importers.py +46 -44
  160. {grow-2.2.3 → grow-2.3.0}/grow/translations/locales.py +33 -45
  161. {grow-2.2.3 → grow-2.3.0}/grow/translations/translation_stats.py +36 -37
  162. {grow-2.2.3 → grow-2.3.0}/grow/translators/base.py +56 -57
  163. {grow-2.2.3 → grow-2.3.0}/grow/translators/errors.py +1 -3
  164. {grow-2.2.3 → grow-2.3.0}/grow/translators/google_sheets.py +442 -384
  165. {grow-2.2.3 → grow-2.3.0}/grow/translators/google_translator_toolkit.py +28 -33
  166. {grow-2.2.3 → grow-2.3.0}/grow/translators/translators.py +6 -9
  167. grow-2.3.0/grow/ui/admin/partials/routes/routes.html +270 -0
  168. grow-2.3.0/grow/ui/admin/views/base.html +69 -0
  169. grow-2.3.0/grow/ui/admin/views/error.html +235 -0
  170. grow-2.3.0/grow/ui/dist/css/admin.min.css +529 -0
  171. grow-2.3.0/grow/ui/dist/css/ui.min.css +159 -0
  172. grow-2.3.0/grow/ui/dist/js/ui.min.js +116 -0
  173. grow-2.3.0/grow.egg-info/PKG-INFO +135 -0
  174. {grow-2.2.3 → grow-2.3.0}/grow.egg-info/SOURCES.txt +4 -6
  175. grow-2.3.0/grow.egg-info/requires.txt +19 -0
  176. grow-2.3.0/pyproject.toml +133 -0
  177. grow-2.2.3/MANIFEST.in +0 -11
  178. grow-2.2.3/PKG-INFO +0 -41
  179. grow-2.2.3/Pipfile +0 -48
  180. grow-2.2.3/README.md +0 -51
  181. grow-2.2.3/description.txt +0 -21
  182. grow-2.2.3/grow/__init__.py +0 -18
  183. grow-2.2.3/grow/commands/__init__.py +0 -24
  184. grow-2.2.3/grow/commands/group.py +0 -58
  185. grow-2.2.3/grow/commands/subcommands/preprocess.py +0 -42
  186. grow-2.2.3/grow/commands/subcommands/run.py +0 -58
  187. grow-2.2.3/grow/commands/subcommands/translations_extract.py +0 -102
  188. grow-2.2.3/grow/commands/subcommands/translations_filter.py +0 -53
  189. grow-2.2.3/grow/commands/subcommands/translations_upload.py +0 -86
  190. grow-2.2.3/grow/common/colors.py +0 -13
  191. grow-2.2.3/grow/common/oauth.py +0 -91
  192. grow-2.2.3/grow/common/patched_site.py +0 -602
  193. grow-2.2.3/grow/common/progressbar_non.py +0 -95
  194. grow-2.2.3/grow/conversion/__init__.py +0 -1
  195. grow-2.2.3/grow/extensions/__init__.py +0 -8
  196. grow-2.2.3/grow/pods/importers.py +0 -12
  197. grow-2.2.3/grow/storage/__init__.py +0 -7
  198. grow-2.2.3/grow/ui/admin/partials/routes/routes.html +0 -22
  199. grow-2.2.3/grow/ui/admin/partials/routes/routes.sass +0 -0
  200. grow-2.2.3/grow/ui/admin/views/base.html +0 -40
  201. grow-2.2.3/grow/ui/admin/views/error.html +0 -145
  202. grow-2.2.3/grow/ui/dist/css/admin.min.css +0 -1
  203. grow-2.2.3/grow/ui/dist/css/ui.min.css +0 -1
  204. grow-2.2.3/grow/ui/dist/js/ui.min.js +0 -1
  205. grow-2.2.3/grow/ui/yarn.lock +0 -3621
  206. grow-2.2.3/grow.egg-info/PKG-INFO +0 -41
  207. grow-2.2.3/grow.egg-info/requires.txt +0 -29
  208. grow-2.2.3/setup.py +0 -68
  209. {grow-2.2.3 → grow-2.3.0}/grow/cache/__init__.py +0 -0
  210. {grow-2.2.3 → grow-2.3.0}/grow/cache/document_cache.py +1 -1
  211. {grow-2.2.3 → grow-2.3.0}/grow/collections/__init__.py +0 -0
  212. {grow-2.2.3 → grow-2.3.0}/grow/commands/subcommands/__init__.py +0 -0
  213. {grow-2.2.3 → grow-2.3.0}/grow/common/__init__.py +0 -0
  214. {grow-2.2.3 → grow-2.3.0}/grow/deployments/__init__.py +0 -0
  215. {grow-2.2.3 → grow-2.3.0}/grow/deployments/destinations/__init__.py +0 -0
  216. {grow-2.2.3 → grow-2.3.0}/grow/deployments/destinations/messages.py +0 -0
  217. {grow-2.2.3 → grow-2.3.0}/grow/documents/__init__.py +0 -0
  218. {grow-2.2.3 → grow-2.3.0}/grow/partials/__init__.py +0 -0
  219. {grow-2.2.3 → grow-2.3.0}/grow/performance/__init__.py +0 -0
  220. {grow-2.2.3 → grow-2.3.0}/grow/pods/__init__.py +0 -0
  221. {grow-2.2.3 → grow-2.3.0}/grow/pods/templates/sitemap.xml +0 -0
  222. {grow-2.2.3 → grow-2.3.0}/grow/preprocessors/__init__.py +0 -0
  223. {grow-2.2.3 → grow-2.3.0}/grow/rendering/__init__.py +0 -0
  224. {grow-2.2.3 → grow-2.3.0}/grow/routing/__init__.py +0 -0
  225. {grow-2.2.3 → grow-2.3.0}/grow/sdk/__init__.py +0 -0
  226. {grow-2.2.3 → grow-2.3.0}/grow/server/__init__.py +0 -0
  227. {grow-2.2.3 → grow-2.3.0}/grow/templates/__init__.py +0 -0
  228. {grow-2.2.3 → grow-2.3.0}/grow/translations/__init__.py +0 -0
  229. {grow-2.2.3 → grow-2.3.0}/grow/translators/__init__.py +0 -0
  230. {grow-2.2.3 → grow-2.3.0}/grow/ui/admin/assets/console.css +0 -0
  231. {grow-2.2.3 → grow-2.3.0}/grow/ui/admin/assets/favicon.png +0 -0
  232. {grow-2.2.3 → grow-2.3.0}/grow/ui/admin/views/catalog.html +0 -0
  233. {grow-2.2.3 → grow-2.3.0}/grow/ui/admin/views/catalogs.html +0 -0
  234. {grow-2.2.3 → grow-2.3.0}/grow/ui/admin/views/collections.html +0 -0
  235. {grow-2.2.3 → grow-2.3.0}/grow/ui/admin/views/main.html +0 -0
  236. {grow-2.2.3 → grow-2.3.0}/grow/ui/admin/views/preprocessors.html +0 -0
  237. {grow-2.2.3 → grow-2.3.0}/grow/ui/admin/views/ui.html +0 -0
  238. {grow-2.2.3 → grow-2.3.0}/grow.egg-info/dependency_links.txt +0 -0
  239. {grow-2.2.3 → grow-2.3.0}/grow.egg-info/entry_points.txt +0 -0
  240. {grow-2.2.3 → grow-2.3.0}/grow.egg-info/not-zip-safe +0 -0
  241. {grow-2.2.3 → grow-2.3.0}/grow.egg-info/top_level.txt +0 -0
  242. {grow-2.2.3 → grow-2.3.0}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2013-2021 The Grow.dev Authors (http://grow.dev)
3
+ Copyright (c) 2013-present The Grow.dev Authors (https://grow.dev)
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
grow-2.3.0/MANIFEST.in ADDED
@@ -0,0 +1,5 @@
1
+ recursive-include grow *
2
+ recursive-exclude * *.pyc *.pyo
3
+ recursive-exclude * *_test.py
4
+ recursive-exclude grow/testing *
5
+ include README.md
grow-2.3.0/PKG-INFO ADDED
@@ -0,0 +1,135 @@
1
+ Metadata-Version: 2.4
2
+ Name: grow
3
+ Version: 2.3.0
4
+ Summary: Develop everywhere and deploy anywhere: a declarative site generator for rapid, high-quality web site production.
5
+ Author-email: "Grow.dev Authors" <code@grow.dev>
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://grow.dev
8
+ Project-URL: Repository, https://github.com/grow/grow
9
+ Keywords: grow,cms,static site generator,content management
10
+ Classifier: Environment :: Web Environment
11
+ Classifier: Intended Audience :: Developers
12
+ Classifier: Operating System :: OS Independent
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python
18
+ Classifier: Topic :: Internet :: WWW/HTTP :: Dynamic Content
19
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
20
+ Requires-Python: >=3.10
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: babel<3,>=2.14
24
+ Requires-Dist: click<9,>=8.1
25
+ Requires-Dist: gitpython<4,>=3.1.41
26
+ Requires-Dist: google-api-python-client<3,>=2.150
27
+ Requires-Dist: html2text>=2024.2.26
28
+ Requires-Dist: httplib2<1,>=0.22
29
+ Requires-Dist: jinja2<4,>=3.1.6
30
+ Requires-Dist: markdown<4,>=3.5
31
+ Requires-Dist: markupsafe<4,>=2.1
32
+ Requires-Dist: oauth2client==4.1.3
33
+ Requires-Dist: protorpc==0.12.0
34
+ Requires-Dist: pygments<3,>=2.17
35
+ Requires-Dist: python-slugify<9,>=8
36
+ Requires-Dist: pyyaml<7,>=6.0.1
37
+ Requires-Dist: translitcodec==0.6.0
38
+ Requires-Dist: watchdog<5,>=3
39
+ Requires-Dist: webob<2,>=1.8.8
40
+ Requires-Dist: webreview==0.3.1
41
+ Requires-Dist: werkzeug<4,>=3.1
42
+ Dynamic: license-file
43
+
44
+ # Grow
45
+
46
+ [![PyPI](https://img.shields.io/pypi/v/grow.svg)](https://pypi.org/project/grow/)
47
+ [![Python](https://img.shields.io/pypi/pyversions/grow.svg)](https://pypi.org/project/grow/)
48
+ [![Test](https://github.com/grow/grow/actions/workflows/test.yml/badge.svg)](https://github.com/grow/grow/actions/workflows/test.yml)
49
+ [![Lint](https://github.com/grow/grow/actions/workflows/lint.yml/badge.svg)](https://github.com/grow/grow/actions/workflows/lint.yml)
50
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
51
+
52
+ > [!NOTE]
53
+ > **Maintenance mode:** Grow is actively maintained for existing v2.x sites with bug fixes and dependency updates, but for new projects we recommend <img src="docs/source/images/rootjs-beet.svg" width="13" height="19" alt="" align="absmiddle">&nbsp;[**Root.js**](https://rootjs.dev) ([GitHub](https://github.com/blinkk/rootjs)) — our modern successor built with TypeScript, Preact/TSX, file routing, i18n, and a built-in CMS.
54
+
55
+ **Grow** is a declarative, file-based static site generator for rapid, high-quality web site production.
56
+
57
+ ## Key Features
58
+
59
+ - **Data-driven content**: Author content in YAML, JSON, and Markdown—keeping content cleanly separated from presentation.
60
+ - **Jinja2 templates**: Bind structured content collections to reusable HTML templates and partials.
61
+ - **Declarative routing & URLs**: Configure URL structures in YAML and reference pages/assets with template tags so URL changes never break links.
62
+ - **Built-in internationalization (i18n)**: Tag strings for translation, manage PO message catalogs, and localize content site-wide or per document.
63
+ - **Integrations**: Pull content from Google Drive/Docs/Sheets and Blogger, or sync translations with Google Sheets.
64
+ - **Deploy anywhere**: Build to a self-contained static fileset (for GitHub Pages, Cloudflare Pages, Netlify, Cloud Storage, or S3) or deploy directly via built-in targets (local, Git, and custom extensions).
65
+
66
+ ## Requirements
67
+
68
+ - Python **3.10 – 3.12**
69
+
70
+ ## Installation
71
+
72
+ Install Grow with [uv](https://docs.astral.sh/uv/) or `pip`:
73
+
74
+ ```bash
75
+ # Install globally as a CLI tool with uv (recommended)
76
+ uv tool install grow
77
+
78
+ # Or install with pip
79
+ pip install grow
80
+ ```
81
+
82
+ ## Quick Start
83
+
84
+ Try the built-in zero-Node starter project in [`examples/starter/`](examples/starter/):
85
+
86
+ ```bash
87
+ git clone https://github.com/grow/grow.git
88
+ cd grow
89
+ uv sync
90
+ uv run grow run examples/starter
91
+ ```
92
+
93
+ Or run the `grow.dev` documentation site locally:
94
+
95
+ ```bash
96
+ uv run grow run docs
97
+ ```
98
+
99
+ ### Common Commands
100
+
101
+ ```bash
102
+ grow run # Start the local development server
103
+ grow build # Build the static site to ./build/
104
+ grow deploy <destination> # Deploy to a configured destination in podspec.yaml
105
+ grow translations extract # Extract translatable strings to message catalogs
106
+ grow --help # Show all available commands
107
+ ```
108
+
109
+ ## Docker
110
+
111
+ Prebuilt images containing Grow, Python, Node.js, Yarn, and Google Cloud CLI are published to Docker Hub and GitHub Container Registry:
112
+
113
+ ```bash
114
+ docker run --rm -it -v "$PWD":/site -w /site grow/base grow build
115
+ ```
116
+
117
+ ## Development
118
+
119
+ Grow uses `uv`, `pytest`, and `ruff` for local development:
120
+
121
+ ```bash
122
+ git clone https://github.com/grow/grow.git
123
+ cd grow
124
+ uv sync
125
+ uv run pytest
126
+ uv run ruff check grow/ install.py
127
+ ```
128
+
129
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contributor guide.
130
+
131
+ ## Documentation & License
132
+
133
+ - Documentation: https://grow.dev
134
+ - Source code: https://github.com/grow/grow
135
+ - License: [MIT](LICENSE)
grow-2.3.0/README.md ADDED
@@ -0,0 +1,92 @@
1
+ # Grow
2
+
3
+ [![PyPI](https://img.shields.io/pypi/v/grow.svg)](https://pypi.org/project/grow/)
4
+ [![Python](https://img.shields.io/pypi/pyversions/grow.svg)](https://pypi.org/project/grow/)
5
+ [![Test](https://github.com/grow/grow/actions/workflows/test.yml/badge.svg)](https://github.com/grow/grow/actions/workflows/test.yml)
6
+ [![Lint](https://github.com/grow/grow/actions/workflows/lint.yml/badge.svg)](https://github.com/grow/grow/actions/workflows/lint.yml)
7
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](LICENSE)
8
+
9
+ > [!NOTE]
10
+ > **Maintenance mode:** Grow is actively maintained for existing v2.x sites with bug fixes and dependency updates, but for new projects we recommend <img src="docs/source/images/rootjs-beet.svg" width="13" height="19" alt="" align="absmiddle">&nbsp;[**Root.js**](https://rootjs.dev) ([GitHub](https://github.com/blinkk/rootjs)) — our modern successor built with TypeScript, Preact/TSX, file routing, i18n, and a built-in CMS.
11
+
12
+ **Grow** is a declarative, file-based static site generator for rapid, high-quality web site production.
13
+
14
+ ## Key Features
15
+
16
+ - **Data-driven content**: Author content in YAML, JSON, and Markdown—keeping content cleanly separated from presentation.
17
+ - **Jinja2 templates**: Bind structured content collections to reusable HTML templates and partials.
18
+ - **Declarative routing & URLs**: Configure URL structures in YAML and reference pages/assets with template tags so URL changes never break links.
19
+ - **Built-in internationalization (i18n)**: Tag strings for translation, manage PO message catalogs, and localize content site-wide or per document.
20
+ - **Integrations**: Pull content from Google Drive/Docs/Sheets and Blogger, or sync translations with Google Sheets.
21
+ - **Deploy anywhere**: Build to a self-contained static fileset (for GitHub Pages, Cloudflare Pages, Netlify, Cloud Storage, or S3) or deploy directly via built-in targets (local, Git, and custom extensions).
22
+
23
+ ## Requirements
24
+
25
+ - Python **3.10 – 3.12**
26
+
27
+ ## Installation
28
+
29
+ Install Grow with [uv](https://docs.astral.sh/uv/) or `pip`:
30
+
31
+ ```bash
32
+ # Install globally as a CLI tool with uv (recommended)
33
+ uv tool install grow
34
+
35
+ # Or install with pip
36
+ pip install grow
37
+ ```
38
+
39
+ ## Quick Start
40
+
41
+ Try the built-in zero-Node starter project in [`examples/starter/`](examples/starter/):
42
+
43
+ ```bash
44
+ git clone https://github.com/grow/grow.git
45
+ cd grow
46
+ uv sync
47
+ uv run grow run examples/starter
48
+ ```
49
+
50
+ Or run the `grow.dev` documentation site locally:
51
+
52
+ ```bash
53
+ uv run grow run docs
54
+ ```
55
+
56
+ ### Common Commands
57
+
58
+ ```bash
59
+ grow run # Start the local development server
60
+ grow build # Build the static site to ./build/
61
+ grow deploy <destination> # Deploy to a configured destination in podspec.yaml
62
+ grow translations extract # Extract translatable strings to message catalogs
63
+ grow --help # Show all available commands
64
+ ```
65
+
66
+ ## Docker
67
+
68
+ Prebuilt images containing Grow, Python, Node.js, Yarn, and Google Cloud CLI are published to Docker Hub and GitHub Container Registry:
69
+
70
+ ```bash
71
+ docker run --rm -it -v "$PWD":/site -w /site grow/base grow build
72
+ ```
73
+
74
+ ## Development
75
+
76
+ Grow uses `uv`, `pytest`, and `ruff` for local development:
77
+
78
+ ```bash
79
+ git clone https://github.com/grow/grow.git
80
+ cd grow
81
+ uv sync
82
+ uv run pytest
83
+ uv run ruff check grow/ install.py
84
+ ```
85
+
86
+ See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contributor guide.
87
+
88
+ ## Documentation & License
89
+
90
+ - Documentation: https://grow.dev
91
+ - Source code: https://github.com/grow/grow
92
+ - License: [MIT](LICENSE)
@@ -0,0 +1,26 @@
1
+ import importlib
2
+ import importlib.metadata
3
+
4
+ try:
5
+ __version__ = importlib.metadata.version('grow')
6
+ except importlib.metadata.PackageNotFoundError:
7
+ __version__ = '2.3.0'
8
+
9
+ _LAZY_EXPORTS = {
10
+ 'Pod': ('grow.pods.pods', 'Pod'),
11
+ 'Preprocessor': ('grow.preprocessors.base', 'BasePreprocessor'),
12
+ 'Translator': ('grow.translators.base', 'Translator'),
13
+ }
14
+
15
+
16
+ def __getattr__(name):
17
+ if name in _LAZY_EXPORTS:
18
+ module_name, attr_name = _LAZY_EXPORTS[name]
19
+ module = importlib.import_module(module_name)
20
+ value = getattr(module, attr_name)
21
+ globals()[name] = value
22
+ return value
23
+ raise AttributeError(f'module {__name__!r} has no attribute {name!r}')
24
+
25
+
26
+ __all__ = ['Pod', 'Preprocessor', 'Translator', '__version__']
@@ -1,3 +1,4 @@
1
1
  if __name__ == '__main__':
2
2
  from .cli import main
3
- main(as_module=True)
3
+
4
+ main(as_module=True)
@@ -5,18 +5,18 @@ Supports caching the collection and caching documents within those collections.
5
5
 
6
6
  import os
7
7
  import threading
8
+
8
9
  from grow.collections import collection
9
10
 
10
11
 
11
12
  class CollectionCache:
12
-
13
13
  def __init__(self):
14
14
  self.reset()
15
15
  self._lock = threading.RLock()
16
16
 
17
17
  @staticmethod
18
18
  def generate_cache_key(pod_path, locale):
19
- return '{}::{}'.format(pod_path, locale)
19
+ return f'{pod_path}::{locale}'
20
20
 
21
21
  def add_collection(self, col):
22
22
  self._cache[col.collection_path] = {
@@ -29,8 +29,7 @@ class CollectionCache:
29
29
  self.ensure_collection(col)
30
30
  # NOTE: Using `doc.locale` causes infinite loop since it needs to load
31
31
  # the fields (which can have circular dependencies).
32
- cache_key = CollectionCache.generate_cache_key(
33
- doc.pod_path, doc.locale_safe)
32
+ cache_key = CollectionCache.generate_cache_key(doc.pod_path, doc.locale_safe)
34
33
  self._cache[col.collection_path]['docs'][cache_key] = doc
35
34
 
36
35
  def add_document_locale(self, doc, locale):
@@ -43,17 +42,15 @@ class CollectionCache:
43
42
  """
44
43
  col = doc.collection
45
44
  self.ensure_collection(col)
46
- cache_key = CollectionCache.generate_cache_key(
47
- doc.pod_path, locale)
45
+ cache_key = CollectionCache.generate_cache_key(doc.pod_path, locale)
48
46
  self._cache[col.collection_path]['docs'][cache_key] = doc
49
47
 
50
48
  def remove_by_path(self, path):
51
49
  """Removes the collection or document based on the path."""
52
50
  if path.startswith(collection.Collection.CONTENT_PATH):
53
- if path.endswith(
54
- '/{}'.format(collection.Collection.BLUEPRINT_PATH)):
51
+ if path.endswith(f'/{collection.Collection.BLUEPRINT_PATH}'):
55
52
  # If this is a blueprint then remove the entire collection.
56
- col_path = path[len(collection.Collection.CONTENT_PATH):]
53
+ col_path = path[len(collection.Collection.CONTENT_PATH) :]
57
54
  # Get just the directory.
58
55
  col_path = os.path.split(col_path)[0]
59
56
  collection_path = col_path[1:] # Remove /
@@ -62,7 +59,7 @@ class CollectionCache:
62
59
  del self._cache[collection_path]
63
60
  else:
64
61
  # Search for an existing collection path.
65
- col_path = path[len(collection.Collection.CONTENT_PATH):]
62
+ col_path = path[len(collection.Collection.CONTENT_PATH) :]
66
63
  col_path = os.path.split(col_path)[0]
67
64
  while col_path != os.sep:
68
65
  collection_path = col_path[1:]
@@ -70,12 +67,10 @@ class CollectionCache:
70
67
  if collection_path in self._cache:
71
68
  # Do a 'wildcard' match on the path to remove all
72
69
  # locales.
73
- generic_key = CollectionCache.generate_cache_key(
74
- path, '')
75
- for key in self._cache[collection_path]['docs'].keys():
70
+ generic_key = CollectionCache.generate_cache_key(path, '')
71
+ for key in self._cache[collection_path]['docs']:
76
72
  if key.startswith(generic_key):
77
- del self._cache[
78
- collection_path]['docs'][key]
73
+ del self._cache[collection_path]['docs'][key]
79
74
  return
80
75
  col_path = os.path.split(col_path)[0]
81
76
 
@@ -88,8 +83,7 @@ class CollectionCache:
88
83
  col = doc.collection
89
84
  with self._lock:
90
85
  if col.collection_path in self._cache:
91
- cache_key = CollectionCache.generate_cache_key(
92
- doc.pod_path, doc.locale_safe)
86
+ cache_key = CollectionCache.generate_cache_key(doc.pod_path, doc.locale_safe)
93
87
  if cache_key in self._cache[col.collection_path]['docs']:
94
88
  del self._cache[col.collection_path]['docs'][cache_key]
95
89
 
@@ -97,8 +91,7 @@ class CollectionCache:
97
91
  col = doc.collection
98
92
  with self._lock:
99
93
  if col.collection_path in self._cache:
100
- cache_key = CollectionCache.generate_cache_key(
101
- doc.pod_path, locale)
94
+ cache_key = CollectionCache.generate_cache_key(doc.pod_path, locale)
102
95
  if cache_key in self._cache[col.collection_path]['docs']:
103
96
  del self._cache[col.collection_path]['docs'][cache_key]
104
97
 
@@ -106,10 +99,9 @@ class CollectionCache:
106
99
  col = doc.collection
107
100
  with self._lock:
108
101
  if col.collection_path in self._cache:
109
- doc_cache_key = CollectionCache.generate_cache_key(
110
- doc.pod_path, '')
102
+ doc_cache_key = CollectionCache.generate_cache_key(doc.pod_path, '')
111
103
  invalid_keys = []
112
- for cache_key in self._cache[col.collection_path]['docs'].keys():
104
+ for cache_key in self._cache[col.collection_path]['docs']:
113
105
  if cache_key.startswith(doc_cache_key):
114
106
  invalid_keys.append(cache_key)
115
107
  for cache_key in invalid_keys:
@@ -121,8 +113,7 @@ class CollectionCache:
121
113
  self.add_collection(col)
122
114
 
123
115
  def get_collection(self, collection_path):
124
- collection_path = collection.Collection.clean_collection_path(
125
- collection_path)
116
+ collection_path = collection.Collection.clean_collection_path(collection_path)
126
117
  if collection_path in self._cache:
127
118
  return self._cache[collection_path]['collection']
128
119
  return None
@@ -130,8 +121,7 @@ class CollectionCache:
130
121
  def get_document(self, col, pod_path, locale):
131
122
  if col.collection_path in self._cache:
132
123
  cache_key = CollectionCache.generate_cache_key(pod_path, locale)
133
- return self._cache[col.collection_path]['docs'].get(
134
- cache_key, None)
124
+ return self._cache[col.collection_path]['docs'].get(cache_key, None)
135
125
  return None
136
126
 
137
127
  def reset(self):
@@ -4,6 +4,7 @@ Cache for storing and retrieving file content at a pod_path.
4
4
  The contents of the cache can be parsed and are stored based on locale.
5
5
  """
6
6
 
7
+
7
8
  class FileCache:
8
9
  """Simple cache for file contents."""
9
10
 
@@ -9,7 +9,6 @@ be shared between locales.
9
9
 
10
10
  import re
11
11
 
12
-
13
12
  FILE_OBJECT_CACHE = 'objectcache.json'
14
13
  FILE_OBJECT_SUB_CACHE = 'objectcache.{}.json'
15
14
 
@@ -3,15 +3,12 @@
3
3
  import json
4
4
  import os
5
5
  import tempfile
6
- from grow.cache import collection_cache
7
- from grow.cache import document_cache
8
- from grow.cache import file_cache
9
- from grow.cache import object_cache
6
+
7
+ from grow.cache import collection_cache, document_cache, file_cache, object_cache
10
8
  from grow.cache import routes_cache as grow_routes_cache
11
9
  from grow.common import json_encoder
12
10
  from grow.pods import dependency
13
11
 
14
-
15
12
  FILE_OBJECT_CACHE = object_cache.FILE_OBJECT_CACHE
16
13
  FILE_ROUTES_CACHE = grow_routes_cache.FILE_ROUTES_CACHE
17
14
 
@@ -20,13 +17,12 @@ class Error(Exception):
20
17
  """General podcache error."""
21
18
 
22
19
  def __init__(self, message):
23
- super(Error, self).__init__(message)
20
+ super().__init__(message)
24
21
  self.message = message
25
22
 
26
23
 
27
24
  class PodCacheParseError(Error):
28
25
  """Error parsing the podcache file."""
29
- pass
30
26
 
31
27
 
32
28
  class PodCache:
@@ -45,8 +41,7 @@ class PodCache:
45
41
  self._dependency_graph.add_all(dep_cache)
46
42
 
47
43
  self._object_caches = {}
48
- self.create_object_cache(
49
- self.KEY_GLOBAL, write_to_file=False, can_reset=True)
44
+ self.create_object_cache(self.KEY_GLOBAL, write_to_file=False, can_reset=True)
50
45
 
51
46
  for key, item in obj_cache.items():
52
47
  # If this is a string, it is written to a separate cache file.
@@ -89,9 +84,7 @@ class PodCache:
89
84
  for meta in self._object_caches.values():
90
85
  if meta['write_to_file'] and meta['cache'].is_dirty:
91
86
  return True
92
- if self.routes_cache.is_dirty:
93
- return True
94
- return False
87
+ return bool(self.routes_cache.is_dirty)
95
88
 
96
89
  @property
97
90
  def object_cache(self):
@@ -105,8 +98,8 @@ class PodCache:
105
98
 
106
99
  def _write_json(self, path, obj):
107
100
  output = json.dumps(
108
- obj, cls=json_encoder.GrowJSONEncoder,
109
- sort_keys=True, indent=2, separators=(',', ': '))
101
+ obj, cls=json_encoder.GrowJSONEncoder, sort_keys=True, indent=2, separators=(',', ': ')
102
+ )
110
103
  temp_dir = self._pod.abs_path('/.grow/tmp')
111
104
  if not os.path.exists(temp_dir):
112
105
  os.makedirs(temp_dir)
@@ -119,8 +112,9 @@ class PodCache:
119
112
  os.makedirs(dir_name)
120
113
  os.rename(temp_path, real_path)
121
114
 
122
- def create_object_cache(self, key, write_to_file=False, can_reset=False, values=None,
123
- separate_file=False):
115
+ def create_object_cache(
116
+ self, key, write_to_file=False, can_reset=False, values=None, separate_file=False
117
+ ):
124
118
  """Create a named object cache."""
125
119
  self._object_caches[key] = {
126
120
  'cache': object_cache.ObjectCache(),
@@ -138,9 +132,8 @@ class PodCache:
138
132
  if key not in self._object_caches:
139
133
  return self.create_object_cache(key, **kwargs)
140
134
  existing_meta = self._object_caches[key]
141
- if 'separate_file' in kwargs:
142
- if existing_meta['separate_file'] != kwargs['separate_file']:
143
- existing_meta['separate_file'] = kwargs['separate_file']
135
+ if 'separate_file' in kwargs and existing_meta['separate_file'] != kwargs['separate_file']:
136
+ existing_meta['separate_file'] = kwargs['separate_file']
144
137
  return existing_meta['cache']
145
138
 
146
139
  def has_object_cache(self, key):
@@ -166,7 +159,7 @@ class PodCache:
166
159
 
167
160
  if obj_cache:
168
161
  for key, meta in obj_cache.items():
169
- if not key in self._object_caches:
162
+ if key not in self._object_caches:
170
163
  self.create_object_cache(key, **meta)
171
164
  else:
172
165
  # Ignore if the object cache is referenced to a different file.
@@ -174,10 +167,8 @@ class PodCache:
174
167
  continue
175
168
 
176
169
  self._object_caches[key]['cache'].add_all(meta['values'])
177
- self._object_caches[key][
178
- 'write_to_file'] = meta['write_to_file']
179
- self._object_caches[key][
180
- 'separate_file'] = meta['separate_file']
170
+ self._object_caches[key]['write_to_file'] = meta['write_to_file']
171
+ self._object_caches[key]['separate_file'] = meta['separate_file']
181
172
  self._object_caches[key]['can_reset'] = meta['can_reset']
182
173
 
183
174
  def write(self):
@@ -186,14 +177,12 @@ class PodCache:
186
177
  if self._dependency_graph.is_dirty:
187
178
  output = self._dependency_graph.export()
188
179
  self._dependency_graph.mark_clean()
189
- self._write_json('{}{}'.format(
190
- self._pod.PATH_CONTROL, self._pod.FILE_DEP_CACHE), output)
180
+ self._write_json(f'{self._pod.PATH_CONTROL}{self._pod.FILE_DEP_CACHE}', output)
191
181
 
192
182
  if self._routes_cache.is_dirty:
193
183
  output = self._routes_cache.export()
194
184
  self._routes_cache.mark_clean()
195
- self._write_json('{}{}'.format(
196
- self._pod.PATH_CONTROL, FILE_ROUTES_CACHE), output)
185
+ self._write_json(f'{self._pod.PATH_CONTROL}{FILE_ROUTES_CACHE}', output)
197
186
 
198
187
  # Write out any of the object caches configured for write_to_file.
199
188
  output = {}
@@ -206,12 +195,11 @@ class PodCache:
206
195
  'separate_file': meta['separate_file'],
207
196
  }
208
197
  if meta['separate_file']:
209
- filename = '/{}'.format(
210
- object_cache.FILE_OBJECT_SUB_CACHE.format(key))
198
+ filename = f'/{object_cache.FILE_OBJECT_SUB_CACHE.format(key)}'
211
199
  self._write_json(filename, cache_info)
212
200
  output[key] = filename
213
201
  else:
214
202
  output[key] = cache_info
215
203
  meta['cache'].mark_clean()
216
204
  if output:
217
- self._write_json('/{}'.format(FILE_OBJECT_CACHE), output)
205
+ self._write_json(f'/{FILE_OBJECT_CACHE}', output)
@@ -4,7 +4,6 @@ Cache for storing and retrieving routing information in a pod.
4
4
 
5
5
  from grow.routing import router
6
6
 
7
-
8
7
  FILE_ROUTES_CACHE = 'routescache.json'
9
8
 
10
9
 
@@ -83,8 +82,10 @@ class RoutesCache:
83
82
  self.add(
84
83
  key,
85
84
  router.RouteInfo.from_data(**item['value']),
86
- options=item['options'], concrete=concrete,
87
- env=env)
85
+ options=item['options'],
86
+ concrete=concrete,
87
+ env=env,
88
+ )
88
89
 
89
90
  def get(self, key, concrete=False, env=None):
90
91
  """Retrieve the value from the cache."""
@@ -0,0 +1,75 @@
1
+ """Lightweight in-memory cache compatible with Jinja2 bytecode caching."""
2
+
3
+ import time
4
+
5
+
6
+ class SimpleCache:
7
+ """In-memory key-value cache with optional per-item expiration."""
8
+
9
+ def __init__(self, threshold=500, default_timeout=300):
10
+ self._cache = {}
11
+ self._threshold = threshold
12
+ self.default_timeout = default_timeout
13
+
14
+ def _normalize_timeout(self, timeout):
15
+ if timeout is None:
16
+ timeout = self.default_timeout
17
+ if timeout > 0:
18
+ return time.monotonic() + timeout
19
+ return 0
20
+
21
+ def _prune(self):
22
+ if len(self._cache) <= self._threshold:
23
+ return
24
+ now = time.monotonic()
25
+ expired = [k for k, (exp, _) in self._cache.items() if exp != 0 and exp <= now]
26
+ for k in expired:
27
+ del self._cache[k]
28
+ while len(self._cache) > self._threshold:
29
+ self._cache.pop(next(iter(self._cache)))
30
+
31
+ def get(self, key):
32
+ entry = self._cache.get(key)
33
+ if entry is None:
34
+ return None
35
+ expires, value = entry
36
+ if expires == 0 or expires > time.monotonic():
37
+ return value
38
+ del self._cache[key]
39
+ return None
40
+
41
+ def set(self, key, value, timeout=None):
42
+ expires = self._normalize_timeout(timeout)
43
+ self._prune()
44
+ self._cache[key] = (expires, value)
45
+ return True
46
+
47
+ def add(self, key, value, timeout=None):
48
+ if self.has(key):
49
+ return False
50
+ return self.set(key, value, timeout=timeout)
51
+
52
+ def delete(self, key):
53
+ return self._cache.pop(key, None) is not None
54
+
55
+ def clear(self):
56
+ self._cache.clear()
57
+ return True
58
+
59
+ def has(self, key):
60
+ entry = self._cache.get(key)
61
+ if entry is None:
62
+ return False
63
+ expires, _ = entry
64
+ if expires == 0 or expires > time.monotonic():
65
+ return True
66
+ del self._cache[key]
67
+ return False
68
+
69
+ def get_many(self, *keys):
70
+ return [self.get(k) for k in keys]
71
+
72
+ def set_many(self, mapping, timeout=None):
73
+ for k, v in mapping.items():
74
+ self.set(k, v, timeout=timeout)
75
+ return True