wandb 0.18.2__py3-none-musllinux_1_2_x86_64.whl

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 (827) hide show
  1. package_readme.md +89 -0
  2. wandb/__init__.py +245 -0
  3. wandb/__init__.pyi +1139 -0
  4. wandb/__main__.py +3 -0
  5. wandb/_globals.py +19 -0
  6. wandb/agents/__init__.py +0 -0
  7. wandb/agents/pyagent.py +363 -0
  8. wandb/analytics/__init__.py +3 -0
  9. wandb/analytics/sentry.py +266 -0
  10. wandb/apis/__init__.py +48 -0
  11. wandb/apis/attrs.py +40 -0
  12. wandb/apis/importers/__init__.py +1 -0
  13. wandb/apis/importers/internals/internal.py +385 -0
  14. wandb/apis/importers/internals/protocols.py +99 -0
  15. wandb/apis/importers/internals/util.py +78 -0
  16. wandb/apis/importers/mlflow.py +254 -0
  17. wandb/apis/importers/validation.py +108 -0
  18. wandb/apis/importers/wandb.py +1603 -0
  19. wandb/apis/internal.py +232 -0
  20. wandb/apis/normalize.py +89 -0
  21. wandb/apis/paginator.py +81 -0
  22. wandb/apis/public/__init__.py +34 -0
  23. wandb/apis/public/api.py +1305 -0
  24. wandb/apis/public/artifacts.py +1090 -0
  25. wandb/apis/public/const.py +4 -0
  26. wandb/apis/public/files.py +195 -0
  27. wandb/apis/public/history.py +149 -0
  28. wandb/apis/public/jobs.py +659 -0
  29. wandb/apis/public/projects.py +154 -0
  30. wandb/apis/public/query_generator.py +166 -0
  31. wandb/apis/public/reports.py +469 -0
  32. wandb/apis/public/runs.py +914 -0
  33. wandb/apis/public/sweeps.py +240 -0
  34. wandb/apis/public/teams.py +198 -0
  35. wandb/apis/public/users.py +136 -0
  36. wandb/apis/reports/__init__.py +1 -0
  37. wandb/apis/reports/v1/__init__.py +8 -0
  38. wandb/apis/reports/v2/__init__.py +8 -0
  39. wandb/apis/workspaces/__init__.py +8 -0
  40. wandb/beta/workflows.py +288 -0
  41. wandb/bin/nvidia_gpu_stats +0 -0
  42. wandb/bin/wandb-core +0 -0
  43. wandb/cli/__init__.py +0 -0
  44. wandb/cli/cli.py +3004 -0
  45. wandb/data_types.py +63 -0
  46. wandb/docker/__init__.py +342 -0
  47. wandb/docker/auth.py +436 -0
  48. wandb/docker/wandb-entrypoint.sh +33 -0
  49. wandb/docker/www_authenticate.py +94 -0
  50. wandb/env.py +514 -0
  51. wandb/errors/__init__.py +17 -0
  52. wandb/errors/errors.py +37 -0
  53. wandb/errors/term.py +103 -0
  54. wandb/errors/util.py +57 -0
  55. wandb/errors/warnings.py +2 -0
  56. wandb/filesync/__init__.py +0 -0
  57. wandb/filesync/dir_watcher.py +403 -0
  58. wandb/filesync/stats.py +100 -0
  59. wandb/filesync/step_checksum.py +142 -0
  60. wandb/filesync/step_prepare.py +179 -0
  61. wandb/filesync/step_upload.py +290 -0
  62. wandb/filesync/upload_job.py +142 -0
  63. wandb/integration/__init__.py +0 -0
  64. wandb/integration/catboost/__init__.py +5 -0
  65. wandb/integration/catboost/catboost.py +178 -0
  66. wandb/integration/cohere/__init__.py +3 -0
  67. wandb/integration/cohere/cohere.py +21 -0
  68. wandb/integration/cohere/resolver.py +347 -0
  69. wandb/integration/diffusers/__init__.py +3 -0
  70. wandb/integration/diffusers/autologger.py +76 -0
  71. wandb/integration/diffusers/pipeline_resolver.py +50 -0
  72. wandb/integration/diffusers/resolvers/__init__.py +9 -0
  73. wandb/integration/diffusers/resolvers/multimodal.py +882 -0
  74. wandb/integration/diffusers/resolvers/utils.py +102 -0
  75. wandb/integration/fastai/__init__.py +249 -0
  76. wandb/integration/gym/__init__.py +105 -0
  77. wandb/integration/huggingface/__init__.py +3 -0
  78. wandb/integration/huggingface/huggingface.py +18 -0
  79. wandb/integration/huggingface/resolver.py +213 -0
  80. wandb/integration/keras/__init__.py +11 -0
  81. wandb/integration/keras/callbacks/__init__.py +5 -0
  82. wandb/integration/keras/callbacks/metrics_logger.py +136 -0
  83. wandb/integration/keras/callbacks/model_checkpoint.py +195 -0
  84. wandb/integration/keras/callbacks/tables_builder.py +226 -0
  85. wandb/integration/keras/keras.py +1091 -0
  86. wandb/integration/kfp/__init__.py +6 -0
  87. wandb/integration/kfp/helpers.py +28 -0
  88. wandb/integration/kfp/kfp_patch.py +324 -0
  89. wandb/integration/kfp/wandb_logging.py +182 -0
  90. wandb/integration/langchain/__init__.py +3 -0
  91. wandb/integration/langchain/wandb_tracer.py +48 -0
  92. wandb/integration/lightgbm/__init__.py +239 -0
  93. wandb/integration/lightning/__init__.py +0 -0
  94. wandb/integration/lightning/fabric/__init__.py +3 -0
  95. wandb/integration/lightning/fabric/logger.py +762 -0
  96. wandb/integration/magic.py +556 -0
  97. wandb/integration/metaflow/__init__.py +3 -0
  98. wandb/integration/metaflow/metaflow.py +383 -0
  99. wandb/integration/openai/__init__.py +3 -0
  100. wandb/integration/openai/fine_tuning.py +480 -0
  101. wandb/integration/openai/openai.py +22 -0
  102. wandb/integration/openai/resolver.py +240 -0
  103. wandb/integration/prodigy/__init__.py +3 -0
  104. wandb/integration/prodigy/prodigy.py +299 -0
  105. wandb/integration/sacred/__init__.py +117 -0
  106. wandb/integration/sagemaker/__init__.py +12 -0
  107. wandb/integration/sagemaker/auth.py +28 -0
  108. wandb/integration/sagemaker/config.py +49 -0
  109. wandb/integration/sagemaker/files.py +3 -0
  110. wandb/integration/sagemaker/resources.py +34 -0
  111. wandb/integration/sb3/__init__.py +3 -0
  112. wandb/integration/sb3/sb3.py +153 -0
  113. wandb/integration/sklearn/__init__.py +37 -0
  114. wandb/integration/sklearn/calculate/__init__.py +32 -0
  115. wandb/integration/sklearn/calculate/calibration_curves.py +125 -0
  116. wandb/integration/sklearn/calculate/class_proportions.py +68 -0
  117. wandb/integration/sklearn/calculate/confusion_matrix.py +93 -0
  118. wandb/integration/sklearn/calculate/decision_boundaries.py +40 -0
  119. wandb/integration/sklearn/calculate/elbow_curve.py +55 -0
  120. wandb/integration/sklearn/calculate/feature_importances.py +67 -0
  121. wandb/integration/sklearn/calculate/learning_curve.py +64 -0
  122. wandb/integration/sklearn/calculate/outlier_candidates.py +69 -0
  123. wandb/integration/sklearn/calculate/residuals.py +86 -0
  124. wandb/integration/sklearn/calculate/silhouette.py +118 -0
  125. wandb/integration/sklearn/calculate/summary_metrics.py +62 -0
  126. wandb/integration/sklearn/plot/__init__.py +35 -0
  127. wandb/integration/sklearn/plot/classifier.py +329 -0
  128. wandb/integration/sklearn/plot/clusterer.py +146 -0
  129. wandb/integration/sklearn/plot/regressor.py +121 -0
  130. wandb/integration/sklearn/plot/shared.py +91 -0
  131. wandb/integration/sklearn/utils.py +183 -0
  132. wandb/integration/tensorboard/__init__.py +10 -0
  133. wandb/integration/tensorboard/log.py +355 -0
  134. wandb/integration/tensorboard/monkeypatch.py +185 -0
  135. wandb/integration/tensorflow/__init__.py +5 -0
  136. wandb/integration/tensorflow/estimator_hook.py +54 -0
  137. wandb/integration/torch/__init__.py +0 -0
  138. wandb/integration/torch/wandb_torch.py +554 -0
  139. wandb/integration/ultralytics/__init__.py +11 -0
  140. wandb/integration/ultralytics/bbox_utils.py +208 -0
  141. wandb/integration/ultralytics/callback.py +524 -0
  142. wandb/integration/ultralytics/classification_utils.py +83 -0
  143. wandb/integration/ultralytics/mask_utils.py +202 -0
  144. wandb/integration/ultralytics/pose_utils.py +103 -0
  145. wandb/integration/xgboost/__init__.py +11 -0
  146. wandb/integration/xgboost/xgboost.py +189 -0
  147. wandb/integration/yolov8/__init__.py +0 -0
  148. wandb/integration/yolov8/yolov8.py +284 -0
  149. wandb/jupyter.py +515 -0
  150. wandb/magic.py +3 -0
  151. wandb/mpmain/__init__.py +0 -0
  152. wandb/mpmain/__main__.py +1 -0
  153. wandb/old/__init__.py +0 -0
  154. wandb/old/core.py +53 -0
  155. wandb/old/settings.py +173 -0
  156. wandb/old/summary.py +440 -0
  157. wandb/plot/__init__.py +19 -0
  158. wandb/plot/bar.py +45 -0
  159. wandb/plot/confusion_matrix.py +100 -0
  160. wandb/plot/histogram.py +39 -0
  161. wandb/plot/line.py +43 -0
  162. wandb/plot/line_series.py +88 -0
  163. wandb/plot/pr_curve.py +136 -0
  164. wandb/plot/roc_curve.py +118 -0
  165. wandb/plot/scatter.py +32 -0
  166. wandb/plot/utils.py +183 -0
  167. wandb/plot/viz.py +123 -0
  168. wandb/proto/__init__.py +0 -0
  169. wandb/proto/v3/__init__.py +0 -0
  170. wandb/proto/v3/wandb_base_pb2.py +55 -0
  171. wandb/proto/v3/wandb_internal_pb2.py +1608 -0
  172. wandb/proto/v3/wandb_server_pb2.py +208 -0
  173. wandb/proto/v3/wandb_settings_pb2.py +112 -0
  174. wandb/proto/v3/wandb_telemetry_pb2.py +106 -0
  175. wandb/proto/v4/__init__.py +0 -0
  176. wandb/proto/v4/wandb_base_pb2.py +30 -0
  177. wandb/proto/v4/wandb_internal_pb2.py +360 -0
  178. wandb/proto/v4/wandb_server_pb2.py +63 -0
  179. wandb/proto/v4/wandb_settings_pb2.py +45 -0
  180. wandb/proto/v4/wandb_telemetry_pb2.py +41 -0
  181. wandb/proto/v5/wandb_base_pb2.py +31 -0
  182. wandb/proto/v5/wandb_internal_pb2.py +361 -0
  183. wandb/proto/v5/wandb_server_pb2.py +64 -0
  184. wandb/proto/v5/wandb_settings_pb2.py +46 -0
  185. wandb/proto/v5/wandb_telemetry_pb2.py +42 -0
  186. wandb/proto/wandb_base_pb2.py +10 -0
  187. wandb/proto/wandb_deprecated.py +53 -0
  188. wandb/proto/wandb_generate_deprecated.py +34 -0
  189. wandb/proto/wandb_generate_proto.py +49 -0
  190. wandb/proto/wandb_internal_pb2.py +16 -0
  191. wandb/proto/wandb_server_pb2.py +10 -0
  192. wandb/proto/wandb_settings_pb2.py +10 -0
  193. wandb/proto/wandb_telemetry_pb2.py +10 -0
  194. wandb/py.typed +0 -0
  195. wandb/sdk/__init__.py +37 -0
  196. wandb/sdk/artifacts/__init__.py +0 -0
  197. wandb/sdk/artifacts/_validators.py +90 -0
  198. wandb/sdk/artifacts/artifact.py +2389 -0
  199. wandb/sdk/artifacts/artifact_download_logger.py +43 -0
  200. wandb/sdk/artifacts/artifact_file_cache.py +253 -0
  201. wandb/sdk/artifacts/artifact_instance_cache.py +17 -0
  202. wandb/sdk/artifacts/artifact_manifest.py +74 -0
  203. wandb/sdk/artifacts/artifact_manifest_entry.py +249 -0
  204. wandb/sdk/artifacts/artifact_manifests/__init__.py +0 -0
  205. wandb/sdk/artifacts/artifact_manifests/artifact_manifest_v1.py +92 -0
  206. wandb/sdk/artifacts/artifact_saver.py +269 -0
  207. wandb/sdk/artifacts/artifact_state.py +11 -0
  208. wandb/sdk/artifacts/artifact_ttl.py +7 -0
  209. wandb/sdk/artifacts/exceptions.py +57 -0
  210. wandb/sdk/artifacts/staging.py +25 -0
  211. wandb/sdk/artifacts/storage_handler.py +62 -0
  212. wandb/sdk/artifacts/storage_handlers/__init__.py +0 -0
  213. wandb/sdk/artifacts/storage_handlers/azure_handler.py +208 -0
  214. wandb/sdk/artifacts/storage_handlers/gcs_handler.py +228 -0
  215. wandb/sdk/artifacts/storage_handlers/http_handler.py +114 -0
  216. wandb/sdk/artifacts/storage_handlers/local_file_handler.py +141 -0
  217. wandb/sdk/artifacts/storage_handlers/multi_handler.py +56 -0
  218. wandb/sdk/artifacts/storage_handlers/s3_handler.py +300 -0
  219. wandb/sdk/artifacts/storage_handlers/tracking_handler.py +72 -0
  220. wandb/sdk/artifacts/storage_handlers/wb_artifact_handler.py +135 -0
  221. wandb/sdk/artifacts/storage_handlers/wb_local_artifact_handler.py +74 -0
  222. wandb/sdk/artifacts/storage_layout.py +6 -0
  223. wandb/sdk/artifacts/storage_policies/__init__.py +4 -0
  224. wandb/sdk/artifacts/storage_policies/register.py +1 -0
  225. wandb/sdk/artifacts/storage_policies/wandb_storage_policy.py +378 -0
  226. wandb/sdk/artifacts/storage_policy.py +72 -0
  227. wandb/sdk/backend/__init__.py +0 -0
  228. wandb/sdk/backend/backend.py +222 -0
  229. wandb/sdk/data_types/__init__.py +0 -0
  230. wandb/sdk/data_types/_dtypes.py +914 -0
  231. wandb/sdk/data_types/_private.py +10 -0
  232. wandb/sdk/data_types/audio.py +165 -0
  233. wandb/sdk/data_types/base_types/__init__.py +0 -0
  234. wandb/sdk/data_types/base_types/json_metadata.py +55 -0
  235. wandb/sdk/data_types/base_types/media.py +315 -0
  236. wandb/sdk/data_types/base_types/wb_value.py +272 -0
  237. wandb/sdk/data_types/bokeh.py +70 -0
  238. wandb/sdk/data_types/graph.py +405 -0
  239. wandb/sdk/data_types/helper_types/__init__.py +0 -0
  240. wandb/sdk/data_types/helper_types/bounding_boxes_2d.py +295 -0
  241. wandb/sdk/data_types/helper_types/classes.py +159 -0
  242. wandb/sdk/data_types/helper_types/image_mask.py +235 -0
  243. wandb/sdk/data_types/histogram.py +96 -0
  244. wandb/sdk/data_types/html.py +115 -0
  245. wandb/sdk/data_types/image.py +845 -0
  246. wandb/sdk/data_types/molecule.py +241 -0
  247. wandb/sdk/data_types/object_3d.py +474 -0
  248. wandb/sdk/data_types/plotly.py +82 -0
  249. wandb/sdk/data_types/saved_model.py +446 -0
  250. wandb/sdk/data_types/table.py +1204 -0
  251. wandb/sdk/data_types/trace_tree.py +438 -0
  252. wandb/sdk/data_types/utils.py +229 -0
  253. wandb/sdk/data_types/video.py +247 -0
  254. wandb/sdk/integration_utils/__init__.py +0 -0
  255. wandb/sdk/integration_utils/auto_logging.py +239 -0
  256. wandb/sdk/integration_utils/data_logging.py +475 -0
  257. wandb/sdk/interface/__init__.py +0 -0
  258. wandb/sdk/interface/constants.py +4 -0
  259. wandb/sdk/interface/interface.py +972 -0
  260. wandb/sdk/interface/interface_queue.py +59 -0
  261. wandb/sdk/interface/interface_relay.py +53 -0
  262. wandb/sdk/interface/interface_shared.py +537 -0
  263. wandb/sdk/interface/interface_sock.py +61 -0
  264. wandb/sdk/interface/message_future.py +27 -0
  265. wandb/sdk/interface/message_future_poll.py +50 -0
  266. wandb/sdk/interface/router.py +118 -0
  267. wandb/sdk/interface/router_queue.py +44 -0
  268. wandb/sdk/interface/router_relay.py +39 -0
  269. wandb/sdk/interface/router_sock.py +36 -0
  270. wandb/sdk/interface/summary_record.py +67 -0
  271. wandb/sdk/internal/__init__.py +0 -0
  272. wandb/sdk/internal/context.py +89 -0
  273. wandb/sdk/internal/datastore.py +297 -0
  274. wandb/sdk/internal/file_pusher.py +181 -0
  275. wandb/sdk/internal/file_stream.py +695 -0
  276. wandb/sdk/internal/flow_control.py +263 -0
  277. wandb/sdk/internal/handler.py +901 -0
  278. wandb/sdk/internal/internal.py +417 -0
  279. wandb/sdk/internal/internal_api.py +4358 -0
  280. wandb/sdk/internal/internal_util.py +100 -0
  281. wandb/sdk/internal/job_builder.py +629 -0
  282. wandb/sdk/internal/profiler.py +78 -0
  283. wandb/sdk/internal/progress.py +83 -0
  284. wandb/sdk/internal/run.py +25 -0
  285. wandb/sdk/internal/sample.py +70 -0
  286. wandb/sdk/internal/sender.py +1686 -0
  287. wandb/sdk/internal/sender_config.py +197 -0
  288. wandb/sdk/internal/settings_static.py +90 -0
  289. wandb/sdk/internal/system/__init__.py +0 -0
  290. wandb/sdk/internal/system/assets/__init__.py +27 -0
  291. wandb/sdk/internal/system/assets/aggregators.py +37 -0
  292. wandb/sdk/internal/system/assets/asset_registry.py +20 -0
  293. wandb/sdk/internal/system/assets/cpu.py +163 -0
  294. wandb/sdk/internal/system/assets/disk.py +210 -0
  295. wandb/sdk/internal/system/assets/gpu.py +416 -0
  296. wandb/sdk/internal/system/assets/gpu_amd.py +239 -0
  297. wandb/sdk/internal/system/assets/gpu_apple.py +177 -0
  298. wandb/sdk/internal/system/assets/interfaces.py +207 -0
  299. wandb/sdk/internal/system/assets/ipu.py +177 -0
  300. wandb/sdk/internal/system/assets/memory.py +166 -0
  301. wandb/sdk/internal/system/assets/network.py +125 -0
  302. wandb/sdk/internal/system/assets/open_metrics.py +299 -0
  303. wandb/sdk/internal/system/assets/tpu.py +154 -0
  304. wandb/sdk/internal/system/assets/trainium.py +399 -0
  305. wandb/sdk/internal/system/env_probe_helpers.py +13 -0
  306. wandb/sdk/internal/system/system_info.py +249 -0
  307. wandb/sdk/internal/system/system_monitor.py +229 -0
  308. wandb/sdk/internal/tb_watcher.py +518 -0
  309. wandb/sdk/internal/thread_local_settings.py +18 -0
  310. wandb/sdk/internal/writer.py +206 -0
  311. wandb/sdk/launch/__init__.py +14 -0
  312. wandb/sdk/launch/_launch.py +330 -0
  313. wandb/sdk/launch/_launch_add.py +255 -0
  314. wandb/sdk/launch/_project_spec.py +566 -0
  315. wandb/sdk/launch/agent/__init__.py +5 -0
  316. wandb/sdk/launch/agent/agent.py +924 -0
  317. wandb/sdk/launch/agent/config.py +296 -0
  318. wandb/sdk/launch/agent/job_status_tracker.py +53 -0
  319. wandb/sdk/launch/agent/run_queue_item_file_saver.py +45 -0
  320. wandb/sdk/launch/builder/__init__.py +0 -0
  321. wandb/sdk/launch/builder/abstract.py +156 -0
  322. wandb/sdk/launch/builder/build.py +297 -0
  323. wandb/sdk/launch/builder/context_manager.py +235 -0
  324. wandb/sdk/launch/builder/docker_builder.py +177 -0
  325. wandb/sdk/launch/builder/kaniko_builder.py +595 -0
  326. wandb/sdk/launch/builder/noop.py +58 -0
  327. wandb/sdk/launch/builder/templates/_wandb_bootstrap.py +188 -0
  328. wandb/sdk/launch/builder/templates/dockerfile.py +92 -0
  329. wandb/sdk/launch/create_job.py +528 -0
  330. wandb/sdk/launch/environment/abstract.py +29 -0
  331. wandb/sdk/launch/environment/aws_environment.py +322 -0
  332. wandb/sdk/launch/environment/azure_environment.py +105 -0
  333. wandb/sdk/launch/environment/gcp_environment.py +335 -0
  334. wandb/sdk/launch/environment/local_environment.py +66 -0
  335. wandb/sdk/launch/errors.py +19 -0
  336. wandb/sdk/launch/git_reference.py +109 -0
  337. wandb/sdk/launch/inputs/files.py +148 -0
  338. wandb/sdk/launch/inputs/internal.py +315 -0
  339. wandb/sdk/launch/inputs/manage.py +113 -0
  340. wandb/sdk/launch/inputs/schema.py +39 -0
  341. wandb/sdk/launch/loader.py +249 -0
  342. wandb/sdk/launch/registry/abstract.py +48 -0
  343. wandb/sdk/launch/registry/anon.py +29 -0
  344. wandb/sdk/launch/registry/azure_container_registry.py +124 -0
  345. wandb/sdk/launch/registry/elastic_container_registry.py +192 -0
  346. wandb/sdk/launch/registry/google_artifact_registry.py +219 -0
  347. wandb/sdk/launch/registry/local_registry.py +67 -0
  348. wandb/sdk/launch/runner/__init__.py +0 -0
  349. wandb/sdk/launch/runner/abstract.py +195 -0
  350. wandb/sdk/launch/runner/kubernetes_monitor.py +474 -0
  351. wandb/sdk/launch/runner/kubernetes_runner.py +963 -0
  352. wandb/sdk/launch/runner/local_container.py +301 -0
  353. wandb/sdk/launch/runner/local_process.py +78 -0
  354. wandb/sdk/launch/runner/sagemaker_runner.py +426 -0
  355. wandb/sdk/launch/runner/vertex_runner.py +230 -0
  356. wandb/sdk/launch/sweeps/__init__.py +39 -0
  357. wandb/sdk/launch/sweeps/scheduler.py +742 -0
  358. wandb/sdk/launch/sweeps/scheduler_sweep.py +91 -0
  359. wandb/sdk/launch/sweeps/utils.py +316 -0
  360. wandb/sdk/launch/utils.py +746 -0
  361. wandb/sdk/launch/wandb_reference.py +138 -0
  362. wandb/sdk/lib/__init__.py +5 -0
  363. wandb/sdk/lib/_settings_toposort_generate.py +159 -0
  364. wandb/sdk/lib/_settings_toposort_generated.py +250 -0
  365. wandb/sdk/lib/_wburls_generate.py +25 -0
  366. wandb/sdk/lib/_wburls_generated.py +22 -0
  367. wandb/sdk/lib/apikey.py +273 -0
  368. wandb/sdk/lib/capped_dict.py +26 -0
  369. wandb/sdk/lib/config_util.py +101 -0
  370. wandb/sdk/lib/credentials.py +141 -0
  371. wandb/sdk/lib/deprecate.py +42 -0
  372. wandb/sdk/lib/disabled.py +29 -0
  373. wandb/sdk/lib/exit_hooks.py +54 -0
  374. wandb/sdk/lib/file_stream_utils.py +118 -0
  375. wandb/sdk/lib/filenames.py +64 -0
  376. wandb/sdk/lib/filesystem.py +372 -0
  377. wandb/sdk/lib/fsm.py +174 -0
  378. wandb/sdk/lib/gitlib.py +239 -0
  379. wandb/sdk/lib/gql_request.py +65 -0
  380. wandb/sdk/lib/handler_util.py +21 -0
  381. wandb/sdk/lib/hashutil.py +84 -0
  382. wandb/sdk/lib/import_hooks.py +275 -0
  383. wandb/sdk/lib/ipython.py +146 -0
  384. wandb/sdk/lib/json_util.py +80 -0
  385. wandb/sdk/lib/lazyloader.py +63 -0
  386. wandb/sdk/lib/mailbox.py +460 -0
  387. wandb/sdk/lib/module.py +69 -0
  388. wandb/sdk/lib/paths.py +106 -0
  389. wandb/sdk/lib/preinit.py +42 -0
  390. wandb/sdk/lib/printer.py +313 -0
  391. wandb/sdk/lib/proto_util.py +90 -0
  392. wandb/sdk/lib/redirect.py +845 -0
  393. wandb/sdk/lib/reporting.py +99 -0
  394. wandb/sdk/lib/retry.py +289 -0
  395. wandb/sdk/lib/run_moment.py +78 -0
  396. wandb/sdk/lib/runid.py +12 -0
  397. wandb/sdk/lib/server.py +52 -0
  398. wandb/sdk/lib/service_connection.py +216 -0
  399. wandb/sdk/lib/service_token.py +94 -0
  400. wandb/sdk/lib/sock_client.py +295 -0
  401. wandb/sdk/lib/sparkline.py +45 -0
  402. wandb/sdk/lib/telemetry.py +100 -0
  403. wandb/sdk/lib/timed_input.py +133 -0
  404. wandb/sdk/lib/timer.py +19 -0
  405. wandb/sdk/lib/tracelog.py +255 -0
  406. wandb/sdk/lib/wburls.py +46 -0
  407. wandb/sdk/service/__init__.py +0 -0
  408. wandb/sdk/service/_startup_debug.py +22 -0
  409. wandb/sdk/service/port_file.py +53 -0
  410. wandb/sdk/service/server.py +116 -0
  411. wandb/sdk/service/server_sock.py +276 -0
  412. wandb/sdk/service/service.py +242 -0
  413. wandb/sdk/service/streams.py +417 -0
  414. wandb/sdk/verify/__init__.py +0 -0
  415. wandb/sdk/verify/verify.py +501 -0
  416. wandb/sdk/wandb_alerts.py +12 -0
  417. wandb/sdk/wandb_config.py +322 -0
  418. wandb/sdk/wandb_helper.py +54 -0
  419. wandb/sdk/wandb_init.py +1266 -0
  420. wandb/sdk/wandb_login.py +349 -0
  421. wandb/sdk/wandb_metric.py +110 -0
  422. wandb/sdk/wandb_require.py +97 -0
  423. wandb/sdk/wandb_require_helpers.py +44 -0
  424. wandb/sdk/wandb_run.py +4236 -0
  425. wandb/sdk/wandb_settings.py +2001 -0
  426. wandb/sdk/wandb_setup.py +409 -0
  427. wandb/sdk/wandb_summary.py +150 -0
  428. wandb/sdk/wandb_sweep.py +119 -0
  429. wandb/sdk/wandb_sync.py +81 -0
  430. wandb/sdk/wandb_watch.py +144 -0
  431. wandb/sklearn.py +35 -0
  432. wandb/sync/__init__.py +3 -0
  433. wandb/sync/sync.py +443 -0
  434. wandb/trigger.py +29 -0
  435. wandb/util.py +1956 -0
  436. wandb/vendor/__init__.py +0 -0
  437. wandb/vendor/gql-0.2.0/setup.py +40 -0
  438. wandb/vendor/gql-0.2.0/tests/__init__.py +0 -0
  439. wandb/vendor/gql-0.2.0/tests/starwars/__init__.py +0 -0
  440. wandb/vendor/gql-0.2.0/tests/starwars/fixtures.py +96 -0
  441. wandb/vendor/gql-0.2.0/tests/starwars/schema.py +146 -0
  442. wandb/vendor/gql-0.2.0/tests/starwars/test_dsl.py +293 -0
  443. wandb/vendor/gql-0.2.0/tests/starwars/test_query.py +355 -0
  444. wandb/vendor/gql-0.2.0/tests/starwars/test_validation.py +171 -0
  445. wandb/vendor/gql-0.2.0/tests/test_client.py +31 -0
  446. wandb/vendor/gql-0.2.0/tests/test_transport.py +89 -0
  447. wandb/vendor/gql-0.2.0/wandb_gql/__init__.py +4 -0
  448. wandb/vendor/gql-0.2.0/wandb_gql/client.py +75 -0
  449. wandb/vendor/gql-0.2.0/wandb_gql/dsl.py +152 -0
  450. wandb/vendor/gql-0.2.0/wandb_gql/gql.py +10 -0
  451. wandb/vendor/gql-0.2.0/wandb_gql/transport/__init__.py +0 -0
  452. wandb/vendor/gql-0.2.0/wandb_gql/transport/http.py +6 -0
  453. wandb/vendor/gql-0.2.0/wandb_gql/transport/local_schema.py +15 -0
  454. wandb/vendor/gql-0.2.0/wandb_gql/transport/requests.py +46 -0
  455. wandb/vendor/gql-0.2.0/wandb_gql/utils.py +21 -0
  456. wandb/vendor/graphql-core-1.1/setup.py +86 -0
  457. wandb/vendor/graphql-core-1.1/wandb_graphql/__init__.py +287 -0
  458. wandb/vendor/graphql-core-1.1/wandb_graphql/error/__init__.py +6 -0
  459. wandb/vendor/graphql-core-1.1/wandb_graphql/error/base.py +42 -0
  460. wandb/vendor/graphql-core-1.1/wandb_graphql/error/format_error.py +11 -0
  461. wandb/vendor/graphql-core-1.1/wandb_graphql/error/located_error.py +29 -0
  462. wandb/vendor/graphql-core-1.1/wandb_graphql/error/syntax_error.py +36 -0
  463. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/__init__.py +26 -0
  464. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/base.py +311 -0
  465. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executor.py +398 -0
  466. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/__init__.py +0 -0
  467. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/asyncio.py +53 -0
  468. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/gevent.py +22 -0
  469. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/process.py +32 -0
  470. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/sync.py +7 -0
  471. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/thread.py +35 -0
  472. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/executors/utils.py +6 -0
  473. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/__init__.py +0 -0
  474. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/executor.py +66 -0
  475. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/fragment.py +252 -0
  476. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/resolver.py +151 -0
  477. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/experimental/utils.py +7 -0
  478. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/middleware.py +57 -0
  479. wandb/vendor/graphql-core-1.1/wandb_graphql/execution/values.py +145 -0
  480. wandb/vendor/graphql-core-1.1/wandb_graphql/graphql.py +60 -0
  481. wandb/vendor/graphql-core-1.1/wandb_graphql/language/__init__.py +0 -0
  482. wandb/vendor/graphql-core-1.1/wandb_graphql/language/ast.py +1349 -0
  483. wandb/vendor/graphql-core-1.1/wandb_graphql/language/base.py +19 -0
  484. wandb/vendor/graphql-core-1.1/wandb_graphql/language/lexer.py +435 -0
  485. wandb/vendor/graphql-core-1.1/wandb_graphql/language/location.py +30 -0
  486. wandb/vendor/graphql-core-1.1/wandb_graphql/language/parser.py +779 -0
  487. wandb/vendor/graphql-core-1.1/wandb_graphql/language/printer.py +193 -0
  488. wandb/vendor/graphql-core-1.1/wandb_graphql/language/source.py +18 -0
  489. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor.py +222 -0
  490. wandb/vendor/graphql-core-1.1/wandb_graphql/language/visitor_meta.py +82 -0
  491. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/__init__.py +0 -0
  492. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/cached_property.py +17 -0
  493. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/contain_subset.py +28 -0
  494. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/default_ordered_dict.py +40 -0
  495. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/ordereddict.py +8 -0
  496. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/pair_set.py +43 -0
  497. wandb/vendor/graphql-core-1.1/wandb_graphql/pyutils/version.py +78 -0
  498. wandb/vendor/graphql-core-1.1/wandb_graphql/type/__init__.py +67 -0
  499. wandb/vendor/graphql-core-1.1/wandb_graphql/type/definition.py +619 -0
  500. wandb/vendor/graphql-core-1.1/wandb_graphql/type/directives.py +132 -0
  501. wandb/vendor/graphql-core-1.1/wandb_graphql/type/introspection.py +440 -0
  502. wandb/vendor/graphql-core-1.1/wandb_graphql/type/scalars.py +131 -0
  503. wandb/vendor/graphql-core-1.1/wandb_graphql/type/schema.py +100 -0
  504. wandb/vendor/graphql-core-1.1/wandb_graphql/type/typemap.py +145 -0
  505. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/__init__.py +0 -0
  506. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/assert_valid_name.py +9 -0
  507. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_from_value.py +65 -0
  508. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_code.py +49 -0
  509. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/ast_to_dict.py +24 -0
  510. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/base.py +75 -0
  511. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_ast_schema.py +291 -0
  512. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/build_client_schema.py +250 -0
  513. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/concat_ast.py +9 -0
  514. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/extend_schema.py +357 -0
  515. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_field_def.py +27 -0
  516. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/get_operation_ast.py +21 -0
  517. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/introspection_query.py +90 -0
  518. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_literal_value.py +67 -0
  519. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/is_valid_value.py +66 -0
  520. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/quoted_or_list.py +21 -0
  521. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/schema_printer.py +168 -0
  522. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/suggestion_list.py +56 -0
  523. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_comparators.py +69 -0
  524. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_from_ast.py +21 -0
  525. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/type_info.py +149 -0
  526. wandb/vendor/graphql-core-1.1/wandb_graphql/utils/value_from_ast.py +69 -0
  527. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/__init__.py +4 -0
  528. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/__init__.py +79 -0
  529. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/arguments_of_correct_type.py +24 -0
  530. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/base.py +8 -0
  531. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/default_values_of_correct_type.py +44 -0
  532. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fields_on_correct_type.py +113 -0
  533. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/fragments_on_composite_types.py +33 -0
  534. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_argument_names.py +70 -0
  535. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_directives.py +97 -0
  536. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_fragment_names.py +19 -0
  537. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/known_type_names.py +43 -0
  538. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/lone_anonymous_operation.py +23 -0
  539. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_fragment_cycles.py +59 -0
  540. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_undefined_variables.py +36 -0
  541. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_fragments.py +38 -0
  542. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/no_unused_variables.py +37 -0
  543. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/overlapping_fields_can_be_merged.py +529 -0
  544. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/possible_fragment_spreads.py +44 -0
  545. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/provided_non_null_arguments.py +46 -0
  546. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/scalar_leafs.py +33 -0
  547. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_argument_names.py +32 -0
  548. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_fragment_names.py +28 -0
  549. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_input_field_names.py +33 -0
  550. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_operation_names.py +31 -0
  551. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/unique_variable_names.py +27 -0
  552. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_are_input_types.py +21 -0
  553. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/rules/variables_in_allowed_position.py +53 -0
  554. wandb/vendor/graphql-core-1.1/wandb_graphql/validation/validation.py +158 -0
  555. wandb/vendor/promise-2.3.0/conftest.py +30 -0
  556. wandb/vendor/promise-2.3.0/setup.py +64 -0
  557. wandb/vendor/promise-2.3.0/tests/__init__.py +0 -0
  558. wandb/vendor/promise-2.3.0/tests/conftest.py +8 -0
  559. wandb/vendor/promise-2.3.0/tests/test_awaitable.py +32 -0
  560. wandb/vendor/promise-2.3.0/tests/test_awaitable_35.py +47 -0
  561. wandb/vendor/promise-2.3.0/tests/test_benchmark.py +116 -0
  562. wandb/vendor/promise-2.3.0/tests/test_complex_threads.py +23 -0
  563. wandb/vendor/promise-2.3.0/tests/test_dataloader.py +452 -0
  564. wandb/vendor/promise-2.3.0/tests/test_dataloader_awaitable_35.py +99 -0
  565. wandb/vendor/promise-2.3.0/tests/test_dataloader_extra.py +65 -0
  566. wandb/vendor/promise-2.3.0/tests/test_extra.py +670 -0
  567. wandb/vendor/promise-2.3.0/tests/test_issues.py +132 -0
  568. wandb/vendor/promise-2.3.0/tests/test_promise_list.py +70 -0
  569. wandb/vendor/promise-2.3.0/tests/test_spec.py +584 -0
  570. wandb/vendor/promise-2.3.0/tests/test_thread_safety.py +115 -0
  571. wandb/vendor/promise-2.3.0/tests/utils.py +3 -0
  572. wandb/vendor/promise-2.3.0/wandb_promise/__init__.py +38 -0
  573. wandb/vendor/promise-2.3.0/wandb_promise/async_.py +135 -0
  574. wandb/vendor/promise-2.3.0/wandb_promise/compat.py +32 -0
  575. wandb/vendor/promise-2.3.0/wandb_promise/dataloader.py +326 -0
  576. wandb/vendor/promise-2.3.0/wandb_promise/iterate_promise.py +12 -0
  577. wandb/vendor/promise-2.3.0/wandb_promise/promise.py +848 -0
  578. wandb/vendor/promise-2.3.0/wandb_promise/promise_list.py +151 -0
  579. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/__init__.py +0 -0
  580. wandb/vendor/promise-2.3.0/wandb_promise/pyutils/version.py +83 -0
  581. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/__init__.py +0 -0
  582. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/asyncio.py +22 -0
  583. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/gevent.py +21 -0
  584. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/immediate.py +27 -0
  585. wandb/vendor/promise-2.3.0/wandb_promise/schedulers/thread.py +18 -0
  586. wandb/vendor/promise-2.3.0/wandb_promise/utils.py +56 -0
  587. wandb/vendor/pygments/__init__.py +90 -0
  588. wandb/vendor/pygments/cmdline.py +568 -0
  589. wandb/vendor/pygments/console.py +74 -0
  590. wandb/vendor/pygments/filter.py +74 -0
  591. wandb/vendor/pygments/filters/__init__.py +350 -0
  592. wandb/vendor/pygments/formatter.py +95 -0
  593. wandb/vendor/pygments/formatters/__init__.py +153 -0
  594. wandb/vendor/pygments/formatters/_mapping.py +85 -0
  595. wandb/vendor/pygments/formatters/bbcode.py +109 -0
  596. wandb/vendor/pygments/formatters/html.py +851 -0
  597. wandb/vendor/pygments/formatters/img.py +600 -0
  598. wandb/vendor/pygments/formatters/irc.py +182 -0
  599. wandb/vendor/pygments/formatters/latex.py +482 -0
  600. wandb/vendor/pygments/formatters/other.py +160 -0
  601. wandb/vendor/pygments/formatters/rtf.py +147 -0
  602. wandb/vendor/pygments/formatters/svg.py +153 -0
  603. wandb/vendor/pygments/formatters/terminal.py +136 -0
  604. wandb/vendor/pygments/formatters/terminal256.py +309 -0
  605. wandb/vendor/pygments/lexer.py +871 -0
  606. wandb/vendor/pygments/lexers/__init__.py +329 -0
  607. wandb/vendor/pygments/lexers/_asy_builtins.py +1645 -0
  608. wandb/vendor/pygments/lexers/_cl_builtins.py +232 -0
  609. wandb/vendor/pygments/lexers/_cocoa_builtins.py +72 -0
  610. wandb/vendor/pygments/lexers/_csound_builtins.py +1346 -0
  611. wandb/vendor/pygments/lexers/_lasso_builtins.py +5327 -0
  612. wandb/vendor/pygments/lexers/_lua_builtins.py +295 -0
  613. wandb/vendor/pygments/lexers/_mapping.py +500 -0
  614. wandb/vendor/pygments/lexers/_mql_builtins.py +1172 -0
  615. wandb/vendor/pygments/lexers/_openedge_builtins.py +2547 -0
  616. wandb/vendor/pygments/lexers/_php_builtins.py +4756 -0
  617. wandb/vendor/pygments/lexers/_postgres_builtins.py +621 -0
  618. wandb/vendor/pygments/lexers/_scilab_builtins.py +3094 -0
  619. wandb/vendor/pygments/lexers/_sourcemod_builtins.py +1163 -0
  620. wandb/vendor/pygments/lexers/_stan_builtins.py +532 -0
  621. wandb/vendor/pygments/lexers/_stata_builtins.py +419 -0
  622. wandb/vendor/pygments/lexers/_tsql_builtins.py +1004 -0
  623. wandb/vendor/pygments/lexers/_vim_builtins.py +1939 -0
  624. wandb/vendor/pygments/lexers/actionscript.py +240 -0
  625. wandb/vendor/pygments/lexers/agile.py +24 -0
  626. wandb/vendor/pygments/lexers/algebra.py +221 -0
  627. wandb/vendor/pygments/lexers/ambient.py +76 -0
  628. wandb/vendor/pygments/lexers/ampl.py +87 -0
  629. wandb/vendor/pygments/lexers/apl.py +101 -0
  630. wandb/vendor/pygments/lexers/archetype.py +318 -0
  631. wandb/vendor/pygments/lexers/asm.py +641 -0
  632. wandb/vendor/pygments/lexers/automation.py +374 -0
  633. wandb/vendor/pygments/lexers/basic.py +500 -0
  634. wandb/vendor/pygments/lexers/bibtex.py +160 -0
  635. wandb/vendor/pygments/lexers/business.py +612 -0
  636. wandb/vendor/pygments/lexers/c_cpp.py +252 -0
  637. wandb/vendor/pygments/lexers/c_like.py +541 -0
  638. wandb/vendor/pygments/lexers/capnproto.py +78 -0
  639. wandb/vendor/pygments/lexers/chapel.py +102 -0
  640. wandb/vendor/pygments/lexers/clean.py +288 -0
  641. wandb/vendor/pygments/lexers/compiled.py +34 -0
  642. wandb/vendor/pygments/lexers/configs.py +833 -0
  643. wandb/vendor/pygments/lexers/console.py +114 -0
  644. wandb/vendor/pygments/lexers/crystal.py +393 -0
  645. wandb/vendor/pygments/lexers/csound.py +366 -0
  646. wandb/vendor/pygments/lexers/css.py +689 -0
  647. wandb/vendor/pygments/lexers/d.py +251 -0
  648. wandb/vendor/pygments/lexers/dalvik.py +125 -0
  649. wandb/vendor/pygments/lexers/data.py +555 -0
  650. wandb/vendor/pygments/lexers/diff.py +165 -0
  651. wandb/vendor/pygments/lexers/dotnet.py +691 -0
  652. wandb/vendor/pygments/lexers/dsls.py +878 -0
  653. wandb/vendor/pygments/lexers/dylan.py +289 -0
  654. wandb/vendor/pygments/lexers/ecl.py +125 -0
  655. wandb/vendor/pygments/lexers/eiffel.py +65 -0
  656. wandb/vendor/pygments/lexers/elm.py +121 -0
  657. wandb/vendor/pygments/lexers/erlang.py +533 -0
  658. wandb/vendor/pygments/lexers/esoteric.py +277 -0
  659. wandb/vendor/pygments/lexers/ezhil.py +69 -0
  660. wandb/vendor/pygments/lexers/factor.py +344 -0
  661. wandb/vendor/pygments/lexers/fantom.py +250 -0
  662. wandb/vendor/pygments/lexers/felix.py +273 -0
  663. wandb/vendor/pygments/lexers/forth.py +177 -0
  664. wandb/vendor/pygments/lexers/fortran.py +205 -0
  665. wandb/vendor/pygments/lexers/foxpro.py +428 -0
  666. wandb/vendor/pygments/lexers/functional.py +21 -0
  667. wandb/vendor/pygments/lexers/go.py +101 -0
  668. wandb/vendor/pygments/lexers/grammar_notation.py +213 -0
  669. wandb/vendor/pygments/lexers/graph.py +80 -0
  670. wandb/vendor/pygments/lexers/graphics.py +553 -0
  671. wandb/vendor/pygments/lexers/haskell.py +843 -0
  672. wandb/vendor/pygments/lexers/haxe.py +936 -0
  673. wandb/vendor/pygments/lexers/hdl.py +382 -0
  674. wandb/vendor/pygments/lexers/hexdump.py +103 -0
  675. wandb/vendor/pygments/lexers/html.py +602 -0
  676. wandb/vendor/pygments/lexers/idl.py +270 -0
  677. wandb/vendor/pygments/lexers/igor.py +288 -0
  678. wandb/vendor/pygments/lexers/inferno.py +96 -0
  679. wandb/vendor/pygments/lexers/installers.py +322 -0
  680. wandb/vendor/pygments/lexers/int_fiction.py +1343 -0
  681. wandb/vendor/pygments/lexers/iolang.py +63 -0
  682. wandb/vendor/pygments/lexers/j.py +146 -0
  683. wandb/vendor/pygments/lexers/javascript.py +1525 -0
  684. wandb/vendor/pygments/lexers/julia.py +333 -0
  685. wandb/vendor/pygments/lexers/jvm.py +1573 -0
  686. wandb/vendor/pygments/lexers/lisp.py +2621 -0
  687. wandb/vendor/pygments/lexers/make.py +202 -0
  688. wandb/vendor/pygments/lexers/markup.py +595 -0
  689. wandb/vendor/pygments/lexers/math.py +21 -0
  690. wandb/vendor/pygments/lexers/matlab.py +663 -0
  691. wandb/vendor/pygments/lexers/ml.py +769 -0
  692. wandb/vendor/pygments/lexers/modeling.py +358 -0
  693. wandb/vendor/pygments/lexers/modula2.py +1561 -0
  694. wandb/vendor/pygments/lexers/monte.py +204 -0
  695. wandb/vendor/pygments/lexers/ncl.py +894 -0
  696. wandb/vendor/pygments/lexers/nimrod.py +159 -0
  697. wandb/vendor/pygments/lexers/nit.py +64 -0
  698. wandb/vendor/pygments/lexers/nix.py +136 -0
  699. wandb/vendor/pygments/lexers/oberon.py +105 -0
  700. wandb/vendor/pygments/lexers/objective.py +504 -0
  701. wandb/vendor/pygments/lexers/ooc.py +85 -0
  702. wandb/vendor/pygments/lexers/other.py +41 -0
  703. wandb/vendor/pygments/lexers/parasail.py +79 -0
  704. wandb/vendor/pygments/lexers/parsers.py +835 -0
  705. wandb/vendor/pygments/lexers/pascal.py +644 -0
  706. wandb/vendor/pygments/lexers/pawn.py +199 -0
  707. wandb/vendor/pygments/lexers/perl.py +620 -0
  708. wandb/vendor/pygments/lexers/php.py +267 -0
  709. wandb/vendor/pygments/lexers/praat.py +294 -0
  710. wandb/vendor/pygments/lexers/prolog.py +306 -0
  711. wandb/vendor/pygments/lexers/python.py +939 -0
  712. wandb/vendor/pygments/lexers/qvt.py +152 -0
  713. wandb/vendor/pygments/lexers/r.py +453 -0
  714. wandb/vendor/pygments/lexers/rdf.py +270 -0
  715. wandb/vendor/pygments/lexers/rebol.py +431 -0
  716. wandb/vendor/pygments/lexers/resource.py +85 -0
  717. wandb/vendor/pygments/lexers/rnc.py +67 -0
  718. wandb/vendor/pygments/lexers/roboconf.py +82 -0
  719. wandb/vendor/pygments/lexers/robotframework.py +560 -0
  720. wandb/vendor/pygments/lexers/ruby.py +519 -0
  721. wandb/vendor/pygments/lexers/rust.py +220 -0
  722. wandb/vendor/pygments/lexers/sas.py +228 -0
  723. wandb/vendor/pygments/lexers/scripting.py +1222 -0
  724. wandb/vendor/pygments/lexers/shell.py +794 -0
  725. wandb/vendor/pygments/lexers/smalltalk.py +195 -0
  726. wandb/vendor/pygments/lexers/smv.py +79 -0
  727. wandb/vendor/pygments/lexers/snobol.py +83 -0
  728. wandb/vendor/pygments/lexers/special.py +103 -0
  729. wandb/vendor/pygments/lexers/sql.py +681 -0
  730. wandb/vendor/pygments/lexers/stata.py +108 -0
  731. wandb/vendor/pygments/lexers/supercollider.py +90 -0
  732. wandb/vendor/pygments/lexers/tcl.py +145 -0
  733. wandb/vendor/pygments/lexers/templates.py +2283 -0
  734. wandb/vendor/pygments/lexers/testing.py +207 -0
  735. wandb/vendor/pygments/lexers/text.py +25 -0
  736. wandb/vendor/pygments/lexers/textedit.py +169 -0
  737. wandb/vendor/pygments/lexers/textfmts.py +297 -0
  738. wandb/vendor/pygments/lexers/theorem.py +458 -0
  739. wandb/vendor/pygments/lexers/trafficscript.py +54 -0
  740. wandb/vendor/pygments/lexers/typoscript.py +226 -0
  741. wandb/vendor/pygments/lexers/urbi.py +133 -0
  742. wandb/vendor/pygments/lexers/varnish.py +190 -0
  743. wandb/vendor/pygments/lexers/verification.py +111 -0
  744. wandb/vendor/pygments/lexers/web.py +24 -0
  745. wandb/vendor/pygments/lexers/webmisc.py +988 -0
  746. wandb/vendor/pygments/lexers/whiley.py +116 -0
  747. wandb/vendor/pygments/lexers/x10.py +69 -0
  748. wandb/vendor/pygments/modeline.py +44 -0
  749. wandb/vendor/pygments/plugin.py +68 -0
  750. wandb/vendor/pygments/regexopt.py +92 -0
  751. wandb/vendor/pygments/scanner.py +105 -0
  752. wandb/vendor/pygments/sphinxext.py +158 -0
  753. wandb/vendor/pygments/style.py +155 -0
  754. wandb/vendor/pygments/styles/__init__.py +80 -0
  755. wandb/vendor/pygments/styles/abap.py +29 -0
  756. wandb/vendor/pygments/styles/algol.py +63 -0
  757. wandb/vendor/pygments/styles/algol_nu.py +63 -0
  758. wandb/vendor/pygments/styles/arduino.py +98 -0
  759. wandb/vendor/pygments/styles/autumn.py +65 -0
  760. wandb/vendor/pygments/styles/borland.py +51 -0
  761. wandb/vendor/pygments/styles/bw.py +49 -0
  762. wandb/vendor/pygments/styles/colorful.py +81 -0
  763. wandb/vendor/pygments/styles/default.py +73 -0
  764. wandb/vendor/pygments/styles/emacs.py +72 -0
  765. wandb/vendor/pygments/styles/friendly.py +72 -0
  766. wandb/vendor/pygments/styles/fruity.py +42 -0
  767. wandb/vendor/pygments/styles/igor.py +29 -0
  768. wandb/vendor/pygments/styles/lovelace.py +97 -0
  769. wandb/vendor/pygments/styles/manni.py +75 -0
  770. wandb/vendor/pygments/styles/monokai.py +106 -0
  771. wandb/vendor/pygments/styles/murphy.py +80 -0
  772. wandb/vendor/pygments/styles/native.py +65 -0
  773. wandb/vendor/pygments/styles/paraiso_dark.py +125 -0
  774. wandb/vendor/pygments/styles/paraiso_light.py +125 -0
  775. wandb/vendor/pygments/styles/pastie.py +75 -0
  776. wandb/vendor/pygments/styles/perldoc.py +69 -0
  777. wandb/vendor/pygments/styles/rainbow_dash.py +89 -0
  778. wandb/vendor/pygments/styles/rrt.py +33 -0
  779. wandb/vendor/pygments/styles/sas.py +44 -0
  780. wandb/vendor/pygments/styles/stata.py +40 -0
  781. wandb/vendor/pygments/styles/tango.py +141 -0
  782. wandb/vendor/pygments/styles/trac.py +63 -0
  783. wandb/vendor/pygments/styles/vim.py +63 -0
  784. wandb/vendor/pygments/styles/vs.py +38 -0
  785. wandb/vendor/pygments/styles/xcode.py +51 -0
  786. wandb/vendor/pygments/token.py +213 -0
  787. wandb/vendor/pygments/unistring.py +217 -0
  788. wandb/vendor/pygments/util.py +388 -0
  789. wandb/vendor/pynvml/__init__.py +0 -0
  790. wandb/vendor/pynvml/pynvml.py +4779 -0
  791. wandb/vendor/watchdog_0_9_0/wandb_watchdog/__init__.py +17 -0
  792. wandb/vendor/watchdog_0_9_0/wandb_watchdog/events.py +615 -0
  793. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/__init__.py +98 -0
  794. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/api.py +369 -0
  795. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents.py +172 -0
  796. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/fsevents2.py +239 -0
  797. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify.py +218 -0
  798. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_buffer.py +81 -0
  799. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/inotify_c.py +575 -0
  800. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/kqueue.py +730 -0
  801. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/polling.py +145 -0
  802. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/read_directory_changes.py +133 -0
  803. wandb/vendor/watchdog_0_9_0/wandb_watchdog/observers/winapi.py +348 -0
  804. wandb/vendor/watchdog_0_9_0/wandb_watchdog/patterns.py +265 -0
  805. wandb/vendor/watchdog_0_9_0/wandb_watchdog/tricks/__init__.py +174 -0
  806. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/__init__.py +151 -0
  807. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/bricks.py +249 -0
  808. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/compat.py +29 -0
  809. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/decorators.py +198 -0
  810. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/delayed_queue.py +88 -0
  811. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/dirsnapshot.py +293 -0
  812. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/echo.py +157 -0
  813. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/event_backport.py +41 -0
  814. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/importlib2.py +40 -0
  815. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/platform.py +57 -0
  816. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/unicode_paths.py +64 -0
  817. wandb/vendor/watchdog_0_9_0/wandb_watchdog/utils/win32stat.py +123 -0
  818. wandb/vendor/watchdog_0_9_0/wandb_watchdog/version.py +28 -0
  819. wandb/vendor/watchdog_0_9_0/wandb_watchdog/watchmedo.py +577 -0
  820. wandb/wandb_agent.py +588 -0
  821. wandb/wandb_controller.py +721 -0
  822. wandb/wandb_run.py +9 -0
  823. wandb-0.18.2.dist-info/METADATA +213 -0
  824. wandb-0.18.2.dist-info/RECORD +827 -0
  825. wandb-0.18.2.dist-info/WHEEL +5 -0
  826. wandb-0.18.2.dist-info/entry_points.txt +3 -0
  827. wandb-0.18.2.dist-info/licenses/LICENSE +21 -0
@@ -0,0 +1,2283 @@
1
+ # -*- coding: utf-8 -*-
2
+ """
3
+ pygments.lexers.templates
4
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
5
+
6
+ Lexers for various template engines' markup.
7
+
8
+ :copyright: Copyright 2006-2017 by the Pygments team, see AUTHORS.
9
+ :license: BSD, see LICENSE for details.
10
+ """
11
+
12
+ import re
13
+
14
+ from pygments.lexers.html import HtmlLexer, XmlLexer
15
+ from pygments.lexers.javascript import JavascriptLexer, LassoLexer
16
+ from pygments.lexers.css import CssLexer
17
+ from pygments.lexers.php import PhpLexer
18
+ from pygments.lexers.python import PythonLexer
19
+ from pygments.lexers.perl import PerlLexer
20
+ from pygments.lexers.jvm import JavaLexer, TeaLangLexer
21
+ from pygments.lexers.data import YamlLexer
22
+ from pygments.lexer import Lexer, DelegatingLexer, RegexLexer, bygroups, \
23
+ include, using, this, default, combined
24
+ from pygments.token import Error, Punctuation, Whitespace, \
25
+ Text, Comment, Operator, Keyword, Name, String, Number, Other, Token
26
+ from pygments.util import html_doctype_matches, looks_like_xml
27
+
28
+ __all__ = ['HtmlPhpLexer', 'XmlPhpLexer', 'CssPhpLexer',
29
+ 'JavascriptPhpLexer', 'ErbLexer', 'RhtmlLexer',
30
+ 'XmlErbLexer', 'CssErbLexer', 'JavascriptErbLexer',
31
+ 'SmartyLexer', 'HtmlSmartyLexer', 'XmlSmartyLexer',
32
+ 'CssSmartyLexer', 'JavascriptSmartyLexer', 'DjangoLexer',
33
+ 'HtmlDjangoLexer', 'CssDjangoLexer', 'XmlDjangoLexer',
34
+ 'JavascriptDjangoLexer', 'GenshiLexer', 'HtmlGenshiLexer',
35
+ 'GenshiTextLexer', 'CssGenshiLexer', 'JavascriptGenshiLexer',
36
+ 'MyghtyLexer', 'MyghtyHtmlLexer', 'MyghtyXmlLexer',
37
+ 'MyghtyCssLexer', 'MyghtyJavascriptLexer', 'MasonLexer', 'MakoLexer',
38
+ 'MakoHtmlLexer', 'MakoXmlLexer', 'MakoJavascriptLexer',
39
+ 'MakoCssLexer', 'JspLexer', 'CheetahLexer', 'CheetahHtmlLexer',
40
+ 'CheetahXmlLexer', 'CheetahJavascriptLexer', 'EvoqueLexer',
41
+ 'EvoqueHtmlLexer', 'EvoqueXmlLexer', 'ColdfusionLexer',
42
+ 'ColdfusionHtmlLexer', 'ColdfusionCFCLexer', 'VelocityLexer',
43
+ 'VelocityHtmlLexer', 'VelocityXmlLexer', 'SspLexer',
44
+ 'TeaTemplateLexer', 'LassoHtmlLexer', 'LassoXmlLexer',
45
+ 'LassoCssLexer', 'LassoJavascriptLexer', 'HandlebarsLexer',
46
+ 'HandlebarsHtmlLexer', 'YamlJinjaLexer', 'LiquidLexer',
47
+ 'TwigLexer', 'TwigHtmlLexer', 'Angular2Lexer', 'Angular2HtmlLexer']
48
+
49
+
50
+ class ErbLexer(Lexer):
51
+ """
52
+ Generic `ERB <http://ruby-doc.org/core/classes/ERB.html>`_ (Ruby Templating)
53
+ lexer.
54
+
55
+ Just highlights ruby code between the preprocessor directives, other data
56
+ is left untouched by the lexer.
57
+
58
+ All options are also forwarded to the `RubyLexer`.
59
+ """
60
+
61
+ name = 'ERB'
62
+ aliases = ['erb']
63
+ mimetypes = ['application/x-ruby-templating']
64
+
65
+ _block_re = re.compile(r'(<%%|%%>|<%=|<%#|<%-|<%|-%>|%>|^%[^%].*?$)', re.M)
66
+
67
+ def __init__(self, **options):
68
+ from pygments.lexers.ruby import RubyLexer
69
+ self.ruby_lexer = RubyLexer(**options)
70
+ Lexer.__init__(self, **options)
71
+
72
+ def get_tokens_unprocessed(self, text):
73
+ """
74
+ Since ERB doesn't allow "<%" and other tags inside of ruby
75
+ blocks we have to use a split approach here that fails for
76
+ that too.
77
+ """
78
+ tokens = self._block_re.split(text)
79
+ tokens.reverse()
80
+ state = idx = 0
81
+ try:
82
+ while True:
83
+ # text
84
+ if state == 0:
85
+ val = tokens.pop()
86
+ yield idx, Other, val
87
+ idx += len(val)
88
+ state = 1
89
+ # block starts
90
+ elif state == 1:
91
+ tag = tokens.pop()
92
+ # literals
93
+ if tag in ('<%%', '%%>'):
94
+ yield idx, Other, tag
95
+ idx += 3
96
+ state = 0
97
+ # comment
98
+ elif tag == '<%#':
99
+ yield idx, Comment.Preproc, tag
100
+ val = tokens.pop()
101
+ yield idx + 3, Comment, val
102
+ idx += 3 + len(val)
103
+ state = 2
104
+ # blocks or output
105
+ elif tag in ('<%', '<%=', '<%-'):
106
+ yield idx, Comment.Preproc, tag
107
+ idx += len(tag)
108
+ data = tokens.pop()
109
+ r_idx = 0
110
+ for r_idx, r_token, r_value in \
111
+ self.ruby_lexer.get_tokens_unprocessed(data):
112
+ yield r_idx + idx, r_token, r_value
113
+ idx += len(data)
114
+ state = 2
115
+ elif tag in ('%>', '-%>'):
116
+ yield idx, Error, tag
117
+ idx += len(tag)
118
+ state = 0
119
+ # % raw ruby statements
120
+ else:
121
+ yield idx, Comment.Preproc, tag[0]
122
+ r_idx = 0
123
+ for r_idx, r_token, r_value in \
124
+ self.ruby_lexer.get_tokens_unprocessed(tag[1:]):
125
+ yield idx + 1 + r_idx, r_token, r_value
126
+ idx += len(tag)
127
+ state = 0
128
+ # block ends
129
+ elif state == 2:
130
+ tag = tokens.pop()
131
+ if tag not in ('%>', '-%>'):
132
+ yield idx, Other, tag
133
+ else:
134
+ yield idx, Comment.Preproc, tag
135
+ idx += len(tag)
136
+ state = 0
137
+ except IndexError:
138
+ return
139
+
140
+ def analyse_text(text):
141
+ if '<%' in text and '%>' in text:
142
+ return 0.4
143
+
144
+
145
+ class SmartyLexer(RegexLexer):
146
+ """
147
+ Generic `Smarty <http://smarty.php.net/>`_ template lexer.
148
+
149
+ Just highlights smarty code between the preprocessor directives, other
150
+ data is left untouched by the lexer.
151
+ """
152
+
153
+ name = 'Smarty'
154
+ aliases = ['smarty']
155
+ filenames = ['*.tpl']
156
+ mimetypes = ['application/x-smarty']
157
+
158
+ flags = re.MULTILINE | re.DOTALL
159
+
160
+ tokens = {
161
+ 'root': [
162
+ (r'[^{]+', Other),
163
+ (r'(\{)(\*.*?\*)(\})',
164
+ bygroups(Comment.Preproc, Comment, Comment.Preproc)),
165
+ (r'(\{php\})(.*?)(\{/php\})',
166
+ bygroups(Comment.Preproc, using(PhpLexer, startinline=True),
167
+ Comment.Preproc)),
168
+ (r'(\{)(/?[a-zA-Z_]\w*)(\s*)',
169
+ bygroups(Comment.Preproc, Name.Function, Text), 'smarty'),
170
+ (r'\{', Comment.Preproc, 'smarty')
171
+ ],
172
+ 'smarty': [
173
+ (r'\s+', Text),
174
+ (r'\{', Comment.Preproc, '#push'),
175
+ (r'\}', Comment.Preproc, '#pop'),
176
+ (r'#[a-zA-Z_]\w*#', Name.Variable),
177
+ (r'\$[a-zA-Z_]\w*(\.\w+)*', Name.Variable),
178
+ (r'[~!%^&*()+=|\[\]:;,.<>/?@-]', Operator),
179
+ (r'(true|false|null)\b', Keyword.Constant),
180
+ (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
181
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
182
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
183
+ (r"'(\\\\|\\'|[^'])*'", String.Single),
184
+ (r'[a-zA-Z_]\w*', Name.Attribute)
185
+ ]
186
+ }
187
+
188
+ def analyse_text(text):
189
+ rv = 0.0
190
+ if re.search('\{if\s+.*?\}.*?\{/if\}', text):
191
+ rv += 0.15
192
+ if re.search('\{include\s+file=.*?\}', text):
193
+ rv += 0.15
194
+ if re.search('\{foreach\s+.*?\}.*?\{/foreach\}', text):
195
+ rv += 0.15
196
+ if re.search('\{\$.*?\}', text):
197
+ rv += 0.01
198
+ return rv
199
+
200
+
201
+ class VelocityLexer(RegexLexer):
202
+ """
203
+ Generic `Velocity <http://velocity.apache.org/>`_ template lexer.
204
+
205
+ Just highlights velocity directives and variable references, other
206
+ data is left untouched by the lexer.
207
+ """
208
+
209
+ name = 'Velocity'
210
+ aliases = ['velocity']
211
+ filenames = ['*.vm', '*.fhtml']
212
+
213
+ flags = re.MULTILINE | re.DOTALL
214
+
215
+ identifier = r'[a-zA-Z_]\w*'
216
+
217
+ tokens = {
218
+ 'root': [
219
+ (r'[^{#$]+', Other),
220
+ (r'(#)(\*.*?\*)(#)',
221
+ bygroups(Comment.Preproc, Comment, Comment.Preproc)),
222
+ (r'(##)(.*?$)',
223
+ bygroups(Comment.Preproc, Comment)),
224
+ (r'(#\{?)(' + identifier + r')(\}?)(\s?\()',
225
+ bygroups(Comment.Preproc, Name.Function, Comment.Preproc, Punctuation),
226
+ 'directiveparams'),
227
+ (r'(#\{?)(' + identifier + r')(\}|\b)',
228
+ bygroups(Comment.Preproc, Name.Function, Comment.Preproc)),
229
+ (r'\$\{?', Punctuation, 'variable')
230
+ ],
231
+ 'variable': [
232
+ (identifier, Name.Variable),
233
+ (r'\(', Punctuation, 'funcparams'),
234
+ (r'(\.)(' + identifier + r')',
235
+ bygroups(Punctuation, Name.Variable), '#push'),
236
+ (r'\}', Punctuation, '#pop'),
237
+ default('#pop')
238
+ ],
239
+ 'directiveparams': [
240
+ (r'(&&|\|\||==?|!=?|[-<>+*%&|^/])|\b(eq|ne|gt|lt|ge|le|not|in)\b',
241
+ Operator),
242
+ (r'\[', Operator, 'rangeoperator'),
243
+ (r'\b' + identifier + r'\b', Name.Function),
244
+ include('funcparams')
245
+ ],
246
+ 'rangeoperator': [
247
+ (r'\.\.', Operator),
248
+ include('funcparams'),
249
+ (r'\]', Operator, '#pop')
250
+ ],
251
+ 'funcparams': [
252
+ (r'\$\{?', Punctuation, 'variable'),
253
+ (r'\s+', Text),
254
+ (r'[,:]', Punctuation),
255
+ (r'"(\\\\|\\"|[^"])*"', String.Double),
256
+ (r"'(\\\\|\\'|[^'])*'", String.Single),
257
+ (r"0[xX][0-9a-fA-F]+[Ll]?", Number),
258
+ (r"\b[0-9]+\b", Number),
259
+ (r'(true|false|null)\b', Keyword.Constant),
260
+ (r'\(', Punctuation, '#push'),
261
+ (r'\)', Punctuation, '#pop'),
262
+ (r'\{', Punctuation, '#push'),
263
+ (r'\}', Punctuation, '#pop'),
264
+ (r'\[', Punctuation, '#push'),
265
+ (r'\]', Punctuation, '#pop'),
266
+ ]
267
+ }
268
+
269
+ def analyse_text(text):
270
+ rv = 0.0
271
+ if re.search(r'#\{?macro\}?\(.*?\).*?#\{?end\}?', text):
272
+ rv += 0.25
273
+ if re.search(r'#\{?if\}?\(.+?\).*?#\{?end\}?', text):
274
+ rv += 0.15
275
+ if re.search(r'#\{?foreach\}?\(.+?\).*?#\{?end\}?', text):
276
+ rv += 0.15
277
+ if re.search(r'\$\{?[a-zA-Z_]\w*(\([^)]*\))?'
278
+ r'(\.\w+(\([^)]*\))?)*\}?', text):
279
+ rv += 0.01
280
+ return rv
281
+
282
+
283
+ class VelocityHtmlLexer(DelegatingLexer):
284
+ """
285
+ Subclass of the `VelocityLexer` that highlights unlexed data
286
+ with the `HtmlLexer`.
287
+
288
+ """
289
+
290
+ name = 'HTML+Velocity'
291
+ aliases = ['html+velocity']
292
+ alias_filenames = ['*.html', '*.fhtml']
293
+ mimetypes = ['text/html+velocity']
294
+
295
+ def __init__(self, **options):
296
+ super(VelocityHtmlLexer, self).__init__(HtmlLexer, VelocityLexer,
297
+ **options)
298
+
299
+
300
+ class VelocityXmlLexer(DelegatingLexer):
301
+ """
302
+ Subclass of the `VelocityLexer` that highlights unlexed data
303
+ with the `XmlLexer`.
304
+
305
+ """
306
+
307
+ name = 'XML+Velocity'
308
+ aliases = ['xml+velocity']
309
+ alias_filenames = ['*.xml', '*.vm']
310
+ mimetypes = ['application/xml+velocity']
311
+
312
+ def __init__(self, **options):
313
+ super(VelocityXmlLexer, self).__init__(XmlLexer, VelocityLexer,
314
+ **options)
315
+
316
+ def analyse_text(text):
317
+ rv = VelocityLexer.analyse_text(text) - 0.01
318
+ if looks_like_xml(text):
319
+ rv += 0.4
320
+ return rv
321
+
322
+
323
+ class DjangoLexer(RegexLexer):
324
+ """
325
+ Generic `django <http://www.djangoproject.com/documentation/templates/>`_
326
+ and `jinja <http://wsgiarea.pocoo.org/jinja/>`_ template lexer.
327
+
328
+ It just highlights django/jinja code between the preprocessor directives,
329
+ other data is left untouched by the lexer.
330
+ """
331
+
332
+ name = 'Django/Jinja'
333
+ aliases = ['django', 'jinja']
334
+ mimetypes = ['application/x-django-templating', 'application/x-jinja']
335
+
336
+ flags = re.M | re.S
337
+
338
+ tokens = {
339
+ 'root': [
340
+ (r'[^{]+', Other),
341
+ (r'\{\{', Comment.Preproc, 'var'),
342
+ # jinja/django comments
343
+ (r'\{[*#].*?[*#]\}', Comment),
344
+ # django comments
345
+ (r'(\{%)(-?\s*)(comment)(\s*-?)(%\})(.*?)'
346
+ r'(\{%)(-?\s*)(endcomment)(\s*-?)(%\})',
347
+ bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc,
348
+ Comment, Comment.Preproc, Text, Keyword, Text,
349
+ Comment.Preproc)),
350
+ # raw jinja blocks
351
+ (r'(\{%)(-?\s*)(raw)(\s*-?)(%\})(.*?)'
352
+ r'(\{%)(-?\s*)(endraw)(\s*-?)(%\})',
353
+ bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc,
354
+ Text, Comment.Preproc, Text, Keyword, Text,
355
+ Comment.Preproc)),
356
+ # filter blocks
357
+ (r'(\{%)(-?\s*)(filter)(\s+)([a-zA-Z_]\w*)',
358
+ bygroups(Comment.Preproc, Text, Keyword, Text, Name.Function),
359
+ 'block'),
360
+ (r'(\{%)(-?\s*)([a-zA-Z_]\w*)',
361
+ bygroups(Comment.Preproc, Text, Keyword), 'block'),
362
+ (r'\{', Other)
363
+ ],
364
+ 'varnames': [
365
+ (r'(\|)(\s*)([a-zA-Z_]\w*)',
366
+ bygroups(Operator, Text, Name.Function)),
367
+ (r'(is)(\s+)(not)?(\s+)?([a-zA-Z_]\w*)',
368
+ bygroups(Keyword, Text, Keyword, Text, Name.Function)),
369
+ (r'(_|true|false|none|True|False|None)\b', Keyword.Pseudo),
370
+ (r'(in|as|reversed|recursive|not|and|or|is|if|else|import|'
371
+ r'with(?:(?:out)?\s*context)?|scoped|ignore\s+missing)\b',
372
+ Keyword),
373
+ (r'(loop|block|super|forloop)\b', Name.Builtin),
374
+ (r'[a-zA-Z_][\w-]*', Name.Variable),
375
+ (r'\.\w+', Name.Variable),
376
+ (r':?"(\\\\|\\"|[^"])*"', String.Double),
377
+ (r":?'(\\\\|\\'|[^'])*'", String.Single),
378
+ (r'([{}()\[\]+\-*/,:~]|[><=]=?)', Operator),
379
+ (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
380
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
381
+ ],
382
+ 'var': [
383
+ (r'\s+', Text),
384
+ (r'(-?)(\}\})', bygroups(Text, Comment.Preproc), '#pop'),
385
+ include('varnames')
386
+ ],
387
+ 'block': [
388
+ (r'\s+', Text),
389
+ (r'(-?)(%\})', bygroups(Text, Comment.Preproc), '#pop'),
390
+ include('varnames'),
391
+ (r'.', Punctuation)
392
+ ]
393
+ }
394
+
395
+ def analyse_text(text):
396
+ rv = 0.0
397
+ if re.search(r'\{%\s*(block|extends)', text) is not None:
398
+ rv += 0.4
399
+ if re.search(r'\{%\s*if\s*.*?%\}', text) is not None:
400
+ rv += 0.1
401
+ if re.search(r'\{\{.*?\}\}', text) is not None:
402
+ rv += 0.1
403
+ return rv
404
+
405
+
406
+ class MyghtyLexer(RegexLexer):
407
+ """
408
+ Generic `myghty templates`_ lexer. Code that isn't Myghty
409
+ markup is yielded as `Token.Other`.
410
+
411
+ .. versionadded:: 0.6
412
+
413
+ .. _myghty templates: http://www.myghty.org/
414
+ """
415
+
416
+ name = 'Myghty'
417
+ aliases = ['myghty']
418
+ filenames = ['*.myt', 'autodelegate']
419
+ mimetypes = ['application/x-myghty']
420
+
421
+ tokens = {
422
+ 'root': [
423
+ (r'\s+', Text),
424
+ (r'(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)',
425
+ bygroups(Name.Tag, Text, Name.Function, Name.Tag,
426
+ using(this), Name.Tag)),
427
+ (r'(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)',
428
+ bygroups(Name.Tag, Name.Function, Name.Tag,
429
+ using(PythonLexer), Name.Tag)),
430
+ (r'(<&[^|])(.*?)(,.*?)?(&>)',
431
+ bygroups(Name.Tag, Name.Function, using(PythonLexer), Name.Tag)),
432
+ (r'(<&\|)(.*?)(,.*?)?(&>)(?s)',
433
+ bygroups(Name.Tag, Name.Function, using(PythonLexer), Name.Tag)),
434
+ (r'</&>', Name.Tag),
435
+ (r'(<%!?)(.*?)(%>)(?s)',
436
+ bygroups(Name.Tag, using(PythonLexer), Name.Tag)),
437
+ (r'(?<=^)#[^\n]*(\n|\Z)', Comment),
438
+ (r'(?<=^)(%)([^\n]*)(\n|\Z)',
439
+ bygroups(Name.Tag, using(PythonLexer), Other)),
440
+ (r"""(?sx)
441
+ (.+?) # anything, followed by:
442
+ (?:
443
+ (?<=\n)(?=[%#]) | # an eval or comment line
444
+ (?=</?[%&]) | # a substitution or block or
445
+ # call start or end
446
+ # - don't consume
447
+ (\\\n) | # an escaped newline
448
+ \Z # end of string
449
+ )""", bygroups(Other, Operator)),
450
+ ]
451
+ }
452
+
453
+
454
+ class MyghtyHtmlLexer(DelegatingLexer):
455
+ """
456
+ Subclass of the `MyghtyLexer` that highlights unlexed data
457
+ with the `HtmlLexer`.
458
+
459
+ .. versionadded:: 0.6
460
+ """
461
+
462
+ name = 'HTML+Myghty'
463
+ aliases = ['html+myghty']
464
+ mimetypes = ['text/html+myghty']
465
+
466
+ def __init__(self, **options):
467
+ super(MyghtyHtmlLexer, self).__init__(HtmlLexer, MyghtyLexer,
468
+ **options)
469
+
470
+
471
+ class MyghtyXmlLexer(DelegatingLexer):
472
+ """
473
+ Subclass of the `MyghtyLexer` that highlights unlexed data
474
+ with the `XmlLexer`.
475
+
476
+ .. versionadded:: 0.6
477
+ """
478
+
479
+ name = 'XML+Myghty'
480
+ aliases = ['xml+myghty']
481
+ mimetypes = ['application/xml+myghty']
482
+
483
+ def __init__(self, **options):
484
+ super(MyghtyXmlLexer, self).__init__(XmlLexer, MyghtyLexer,
485
+ **options)
486
+
487
+
488
+ class MyghtyJavascriptLexer(DelegatingLexer):
489
+ """
490
+ Subclass of the `MyghtyLexer` that highlights unlexed data
491
+ with the `JavascriptLexer`.
492
+
493
+ .. versionadded:: 0.6
494
+ """
495
+
496
+ name = 'JavaScript+Myghty'
497
+ aliases = ['js+myghty', 'javascript+myghty']
498
+ mimetypes = ['application/x-javascript+myghty',
499
+ 'text/x-javascript+myghty',
500
+ 'text/javascript+mygthy']
501
+
502
+ def __init__(self, **options):
503
+ super(MyghtyJavascriptLexer, self).__init__(JavascriptLexer,
504
+ MyghtyLexer, **options)
505
+
506
+
507
+ class MyghtyCssLexer(DelegatingLexer):
508
+ """
509
+ Subclass of the `MyghtyLexer` that highlights unlexed data
510
+ with the `CssLexer`.
511
+
512
+ .. versionadded:: 0.6
513
+ """
514
+
515
+ name = 'CSS+Myghty'
516
+ aliases = ['css+myghty']
517
+ mimetypes = ['text/css+myghty']
518
+
519
+ def __init__(self, **options):
520
+ super(MyghtyCssLexer, self).__init__(CssLexer, MyghtyLexer,
521
+ **options)
522
+
523
+
524
+ class MasonLexer(RegexLexer):
525
+ """
526
+ Generic `mason templates`_ lexer. Stolen from Myghty lexer. Code that isn't
527
+ Mason markup is HTML.
528
+
529
+ .. _mason templates: http://www.masonhq.com/
530
+
531
+ .. versionadded:: 1.4
532
+ """
533
+ name = 'Mason'
534
+ aliases = ['mason']
535
+ filenames = ['*.m', '*.mhtml', '*.mc', '*.mi', 'autohandler', 'dhandler']
536
+ mimetypes = ['application/x-mason']
537
+
538
+ tokens = {
539
+ 'root': [
540
+ (r'\s+', Text),
541
+ (r'(<%doc>)(.*?)(</%doc>)(?s)',
542
+ bygroups(Name.Tag, Comment.Multiline, Name.Tag)),
543
+ (r'(<%(?:def|method))(\s*)(.*?)(>)(.*?)(</%\2\s*>)(?s)',
544
+ bygroups(Name.Tag, Text, Name.Function, Name.Tag,
545
+ using(this), Name.Tag)),
546
+ (r'(<%\w+)(.*?)(>)(.*?)(</%\2\s*>)(?s)',
547
+ bygroups(Name.Tag, Name.Function, Name.Tag,
548
+ using(PerlLexer), Name.Tag)),
549
+ (r'(<&[^|])(.*?)(,.*?)?(&>)(?s)',
550
+ bygroups(Name.Tag, Name.Function, using(PerlLexer), Name.Tag)),
551
+ (r'(<&\|)(.*?)(,.*?)?(&>)(?s)',
552
+ bygroups(Name.Tag, Name.Function, using(PerlLexer), Name.Tag)),
553
+ (r'</&>', Name.Tag),
554
+ (r'(<%!?)(.*?)(%>)(?s)',
555
+ bygroups(Name.Tag, using(PerlLexer), Name.Tag)),
556
+ (r'(?<=^)#[^\n]*(\n|\Z)', Comment),
557
+ (r'(?<=^)(%)([^\n]*)(\n|\Z)',
558
+ bygroups(Name.Tag, using(PerlLexer), Other)),
559
+ (r"""(?sx)
560
+ (.+?) # anything, followed by:
561
+ (?:
562
+ (?<=\n)(?=[%#]) | # an eval or comment line
563
+ (?=</?[%&]) | # a substitution or block or
564
+ # call start or end
565
+ # - don't consume
566
+ (\\\n) | # an escaped newline
567
+ \Z # end of string
568
+ )""", bygroups(using(HtmlLexer), Operator)),
569
+ ]
570
+ }
571
+
572
+ def analyse_text(text):
573
+ result = 0.0
574
+ if re.search(r'</%(class|doc|init)%>', text) is not None:
575
+ result = 1.0
576
+ elif re.search(r'<&.+&>', text, re.DOTALL) is not None:
577
+ result = 0.11
578
+ return result
579
+
580
+
581
+ class MakoLexer(RegexLexer):
582
+ """
583
+ Generic `mako templates`_ lexer. Code that isn't Mako
584
+ markup is yielded as `Token.Other`.
585
+
586
+ .. versionadded:: 0.7
587
+
588
+ .. _mako templates: http://www.makotemplates.org/
589
+ """
590
+
591
+ name = 'Mako'
592
+ aliases = ['mako']
593
+ filenames = ['*.mao']
594
+ mimetypes = ['application/x-mako']
595
+
596
+ tokens = {
597
+ 'root': [
598
+ (r'(\s*)(%)(\s*end(?:\w+))(\n|\Z)',
599
+ bygroups(Text, Comment.Preproc, Keyword, Other)),
600
+ (r'(\s*)(%)([^\n]*)(\n|\Z)',
601
+ bygroups(Text, Comment.Preproc, using(PythonLexer), Other)),
602
+ (r'(\s*)(##[^\n]*)(\n|\Z)',
603
+ bygroups(Text, Comment.Preproc, Other)),
604
+ (r'(?s)<%doc>.*?</%doc>', Comment.Preproc),
605
+ (r'(<%)([\w.:]+)',
606
+ bygroups(Comment.Preproc, Name.Builtin), 'tag'),
607
+ (r'(</%)([\w.:]+)(>)',
608
+ bygroups(Comment.Preproc, Name.Builtin, Comment.Preproc)),
609
+ (r'<%(?=([\w.:]+))', Comment.Preproc, 'ondeftags'),
610
+ (r'(<%(?:!?))(.*?)(%>)(?s)',
611
+ bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
612
+ (r'(\$\{)(.*?)(\})',
613
+ bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
614
+ (r'''(?sx)
615
+ (.+?) # anything, followed by:
616
+ (?:
617
+ (?<=\n)(?=%|\#\#) | # an eval or comment line
618
+ (?=\#\*) | # multiline comment
619
+ (?=</?%) | # a python block
620
+ # call start or end
621
+ (?=\$\{) | # a substitution
622
+ (?<=\n)(?=\s*%) |
623
+ # - don't consume
624
+ (\\\n) | # an escaped newline
625
+ \Z # end of string
626
+ )
627
+ ''', bygroups(Other, Operator)),
628
+ (r'\s+', Text),
629
+ ],
630
+ 'ondeftags': [
631
+ (r'<%', Comment.Preproc),
632
+ (r'(?<=<%)(include|inherit|namespace|page)', Name.Builtin),
633
+ include('tag'),
634
+ ],
635
+ 'tag': [
636
+ (r'((?:\w+)\s*=)(\s*)(".*?")',
637
+ bygroups(Name.Attribute, Text, String)),
638
+ (r'/?\s*>', Comment.Preproc, '#pop'),
639
+ (r'\s+', Text),
640
+ ],
641
+ 'attr': [
642
+ ('".*?"', String, '#pop'),
643
+ ("'.*?'", String, '#pop'),
644
+ (r'[^\s>]+', String, '#pop'),
645
+ ],
646
+ }
647
+
648
+
649
+ class MakoHtmlLexer(DelegatingLexer):
650
+ """
651
+ Subclass of the `MakoLexer` that highlights unlexed data
652
+ with the `HtmlLexer`.
653
+
654
+ .. versionadded:: 0.7
655
+ """
656
+
657
+ name = 'HTML+Mako'
658
+ aliases = ['html+mako']
659
+ mimetypes = ['text/html+mako']
660
+
661
+ def __init__(self, **options):
662
+ super(MakoHtmlLexer, self).__init__(HtmlLexer, MakoLexer,
663
+ **options)
664
+
665
+
666
+ class MakoXmlLexer(DelegatingLexer):
667
+ """
668
+ Subclass of the `MakoLexer` that highlights unlexed data
669
+ with the `XmlLexer`.
670
+
671
+ .. versionadded:: 0.7
672
+ """
673
+
674
+ name = 'XML+Mako'
675
+ aliases = ['xml+mako']
676
+ mimetypes = ['application/xml+mako']
677
+
678
+ def __init__(self, **options):
679
+ super(MakoXmlLexer, self).__init__(XmlLexer, MakoLexer,
680
+ **options)
681
+
682
+
683
+ class MakoJavascriptLexer(DelegatingLexer):
684
+ """
685
+ Subclass of the `MakoLexer` that highlights unlexed data
686
+ with the `JavascriptLexer`.
687
+
688
+ .. versionadded:: 0.7
689
+ """
690
+
691
+ name = 'JavaScript+Mako'
692
+ aliases = ['js+mako', 'javascript+mako']
693
+ mimetypes = ['application/x-javascript+mako',
694
+ 'text/x-javascript+mako',
695
+ 'text/javascript+mako']
696
+
697
+ def __init__(self, **options):
698
+ super(MakoJavascriptLexer, self).__init__(JavascriptLexer,
699
+ MakoLexer, **options)
700
+
701
+
702
+ class MakoCssLexer(DelegatingLexer):
703
+ """
704
+ Subclass of the `MakoLexer` that highlights unlexed data
705
+ with the `CssLexer`.
706
+
707
+ .. versionadded:: 0.7
708
+ """
709
+
710
+ name = 'CSS+Mako'
711
+ aliases = ['css+mako']
712
+ mimetypes = ['text/css+mako']
713
+
714
+ def __init__(self, **options):
715
+ super(MakoCssLexer, self).__init__(CssLexer, MakoLexer,
716
+ **options)
717
+
718
+
719
+ # Genshi and Cheetah lexers courtesy of Matt Good.
720
+
721
+ class CheetahPythonLexer(Lexer):
722
+ """
723
+ Lexer for handling Cheetah's special $ tokens in Python syntax.
724
+ """
725
+
726
+ def get_tokens_unprocessed(self, text):
727
+ pylexer = PythonLexer(**self.options)
728
+ for pos, type_, value in pylexer.get_tokens_unprocessed(text):
729
+ if type_ == Token.Error and value == '$':
730
+ type_ = Comment.Preproc
731
+ yield pos, type_, value
732
+
733
+
734
+ class CheetahLexer(RegexLexer):
735
+ """
736
+ Generic `cheetah templates`_ lexer. Code that isn't Cheetah
737
+ markup is yielded as `Token.Other`. This also works for
738
+ `spitfire templates`_ which use the same syntax.
739
+
740
+ .. _cheetah templates: http://www.cheetahtemplate.org/
741
+ .. _spitfire templates: http://code.google.com/p/spitfire/
742
+ """
743
+
744
+ name = 'Cheetah'
745
+ aliases = ['cheetah', 'spitfire']
746
+ filenames = ['*.tmpl', '*.spt']
747
+ mimetypes = ['application/x-cheetah', 'application/x-spitfire']
748
+
749
+ tokens = {
750
+ 'root': [
751
+ (r'(##[^\n]*)$',
752
+ (bygroups(Comment))),
753
+ (r'#[*](.|\n)*?[*]#', Comment),
754
+ (r'#end[^#\n]*(?:#|$)', Comment.Preproc),
755
+ (r'#slurp$', Comment.Preproc),
756
+ (r'(#[a-zA-Z]+)([^#\n]*)(#|$)',
757
+ (bygroups(Comment.Preproc, using(CheetahPythonLexer),
758
+ Comment.Preproc))),
759
+ # TODO support other Python syntax like $foo['bar']
760
+ (r'(\$)([a-zA-Z_][\w.]*\w)',
761
+ bygroups(Comment.Preproc, using(CheetahPythonLexer))),
762
+ (r'(\$\{!?)(.*?)(\})(?s)',
763
+ bygroups(Comment.Preproc, using(CheetahPythonLexer),
764
+ Comment.Preproc)),
765
+ (r'''(?sx)
766
+ (.+?) # anything, followed by:
767
+ (?:
768
+ (?=\#[#a-zA-Z]*) | # an eval comment
769
+ (?=\$[a-zA-Z_{]) | # a substitution
770
+ \Z # end of string
771
+ )
772
+ ''', Other),
773
+ (r'\s+', Text),
774
+ ],
775
+ }
776
+
777
+
778
+ class CheetahHtmlLexer(DelegatingLexer):
779
+ """
780
+ Subclass of the `CheetahLexer` that highlights unlexed data
781
+ with the `HtmlLexer`.
782
+ """
783
+
784
+ name = 'HTML+Cheetah'
785
+ aliases = ['html+cheetah', 'html+spitfire', 'htmlcheetah']
786
+ mimetypes = ['text/html+cheetah', 'text/html+spitfire']
787
+
788
+ def __init__(self, **options):
789
+ super(CheetahHtmlLexer, self).__init__(HtmlLexer, CheetahLexer,
790
+ **options)
791
+
792
+
793
+ class CheetahXmlLexer(DelegatingLexer):
794
+ """
795
+ Subclass of the `CheetahLexer` that highlights unlexed data
796
+ with the `XmlLexer`.
797
+ """
798
+
799
+ name = 'XML+Cheetah'
800
+ aliases = ['xml+cheetah', 'xml+spitfire']
801
+ mimetypes = ['application/xml+cheetah', 'application/xml+spitfire']
802
+
803
+ def __init__(self, **options):
804
+ super(CheetahXmlLexer, self).__init__(XmlLexer, CheetahLexer,
805
+ **options)
806
+
807
+
808
+ class CheetahJavascriptLexer(DelegatingLexer):
809
+ """
810
+ Subclass of the `CheetahLexer` that highlights unlexed data
811
+ with the `JavascriptLexer`.
812
+ """
813
+
814
+ name = 'JavaScript+Cheetah'
815
+ aliases = ['js+cheetah', 'javascript+cheetah',
816
+ 'js+spitfire', 'javascript+spitfire']
817
+ mimetypes = ['application/x-javascript+cheetah',
818
+ 'text/x-javascript+cheetah',
819
+ 'text/javascript+cheetah',
820
+ 'application/x-javascript+spitfire',
821
+ 'text/x-javascript+spitfire',
822
+ 'text/javascript+spitfire']
823
+
824
+ def __init__(self, **options):
825
+ super(CheetahJavascriptLexer, self).__init__(JavascriptLexer,
826
+ CheetahLexer, **options)
827
+
828
+
829
+ class GenshiTextLexer(RegexLexer):
830
+ """
831
+ A lexer that highlights `genshi <http://genshi.edgewall.org/>`_ text
832
+ templates.
833
+ """
834
+
835
+ name = 'Genshi Text'
836
+ aliases = ['genshitext']
837
+ mimetypes = ['application/x-genshi-text', 'text/x-genshi']
838
+
839
+ tokens = {
840
+ 'root': [
841
+ (r'[^#$\s]+', Other),
842
+ (r'^(\s*)(##.*)$', bygroups(Text, Comment)),
843
+ (r'^(\s*)(#)', bygroups(Text, Comment.Preproc), 'directive'),
844
+ include('variable'),
845
+ (r'[#$\s]', Other),
846
+ ],
847
+ 'directive': [
848
+ (r'\n', Text, '#pop'),
849
+ (r'(?:def|for|if)\s+.*', using(PythonLexer), '#pop'),
850
+ (r'(choose|when|with)([^\S\n]+)(.*)',
851
+ bygroups(Keyword, Text, using(PythonLexer)), '#pop'),
852
+ (r'(choose|otherwise)\b', Keyword, '#pop'),
853
+ (r'(end\w*)([^\S\n]*)(.*)', bygroups(Keyword, Text, Comment), '#pop'),
854
+ ],
855
+ 'variable': [
856
+ (r'(?<!\$)(\$\{)(.+?)(\})',
857
+ bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
858
+ (r'(?<!\$)(\$)([a-zA-Z_][\w.]*)',
859
+ Name.Variable),
860
+ ]
861
+ }
862
+
863
+
864
+ class GenshiMarkupLexer(RegexLexer):
865
+ """
866
+ Base lexer for Genshi markup, used by `HtmlGenshiLexer` and
867
+ `GenshiLexer`.
868
+ """
869
+
870
+ flags = re.DOTALL
871
+
872
+ tokens = {
873
+ 'root': [
874
+ (r'[^<$]+', Other),
875
+ (r'(<\?python)(.*?)(\?>)',
876
+ bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
877
+ # yield style and script blocks as Other
878
+ (r'<\s*(script|style)\s*.*?>.*?<\s*/\1\s*>', Other),
879
+ (r'<\s*py:[a-zA-Z0-9]+', Name.Tag, 'pytag'),
880
+ (r'<\s*[a-zA-Z0-9:.]+', Name.Tag, 'tag'),
881
+ include('variable'),
882
+ (r'[<$]', Other),
883
+ ],
884
+ 'pytag': [
885
+ (r'\s+', Text),
886
+ (r'[\w:-]+\s*=', Name.Attribute, 'pyattr'),
887
+ (r'/?\s*>', Name.Tag, '#pop'),
888
+ ],
889
+ 'pyattr': [
890
+ ('(")(.*?)(")', bygroups(String, using(PythonLexer), String), '#pop'),
891
+ ("(')(.*?)(')", bygroups(String, using(PythonLexer), String), '#pop'),
892
+ (r'[^\s>]+', String, '#pop'),
893
+ ],
894
+ 'tag': [
895
+ (r'\s+', Text),
896
+ (r'py:[\w-]+\s*=', Name.Attribute, 'pyattr'),
897
+ (r'[\w:-]+\s*=', Name.Attribute, 'attr'),
898
+ (r'/?\s*>', Name.Tag, '#pop'),
899
+ ],
900
+ 'attr': [
901
+ ('"', String, 'attr-dstring'),
902
+ ("'", String, 'attr-sstring'),
903
+ (r'[^\s>]*', String, '#pop')
904
+ ],
905
+ 'attr-dstring': [
906
+ ('"', String, '#pop'),
907
+ include('strings'),
908
+ ("'", String)
909
+ ],
910
+ 'attr-sstring': [
911
+ ("'", String, '#pop'),
912
+ include('strings'),
913
+ ("'", String)
914
+ ],
915
+ 'strings': [
916
+ ('[^"\'$]+', String),
917
+ include('variable')
918
+ ],
919
+ 'variable': [
920
+ (r'(?<!\$)(\$\{)(.+?)(\})',
921
+ bygroups(Comment.Preproc, using(PythonLexer), Comment.Preproc)),
922
+ (r'(?<!\$)(\$)([a-zA-Z_][\w\.]*)',
923
+ Name.Variable),
924
+ ]
925
+ }
926
+
927
+
928
+ class HtmlGenshiLexer(DelegatingLexer):
929
+ """
930
+ A lexer that highlights `genshi <http://genshi.edgewall.org/>`_ and
931
+ `kid <http://kid-templating.org/>`_ kid HTML templates.
932
+ """
933
+
934
+ name = 'HTML+Genshi'
935
+ aliases = ['html+genshi', 'html+kid']
936
+ alias_filenames = ['*.html', '*.htm', '*.xhtml']
937
+ mimetypes = ['text/html+genshi']
938
+
939
+ def __init__(self, **options):
940
+ super(HtmlGenshiLexer, self).__init__(HtmlLexer, GenshiMarkupLexer,
941
+ **options)
942
+
943
+ def analyse_text(text):
944
+ rv = 0.0
945
+ if re.search('\$\{.*?\}', text) is not None:
946
+ rv += 0.2
947
+ if re.search('py:(.*?)=["\']', text) is not None:
948
+ rv += 0.2
949
+ return rv + HtmlLexer.analyse_text(text) - 0.01
950
+
951
+
952
+ class GenshiLexer(DelegatingLexer):
953
+ """
954
+ A lexer that highlights `genshi <http://genshi.edgewall.org/>`_ and
955
+ `kid <http://kid-templating.org/>`_ kid XML templates.
956
+ """
957
+
958
+ name = 'Genshi'
959
+ aliases = ['genshi', 'kid', 'xml+genshi', 'xml+kid']
960
+ filenames = ['*.kid']
961
+ alias_filenames = ['*.xml']
962
+ mimetypes = ['application/x-genshi', 'application/x-kid']
963
+
964
+ def __init__(self, **options):
965
+ super(GenshiLexer, self).__init__(XmlLexer, GenshiMarkupLexer,
966
+ **options)
967
+
968
+ def analyse_text(text):
969
+ rv = 0.0
970
+ if re.search('\$\{.*?\}', text) is not None:
971
+ rv += 0.2
972
+ if re.search('py:(.*?)=["\']', text) is not None:
973
+ rv += 0.2
974
+ return rv + XmlLexer.analyse_text(text) - 0.01
975
+
976
+
977
+ class JavascriptGenshiLexer(DelegatingLexer):
978
+ """
979
+ A lexer that highlights javascript code in genshi text templates.
980
+ """
981
+
982
+ name = 'JavaScript+Genshi Text'
983
+ aliases = ['js+genshitext', 'js+genshi', 'javascript+genshitext',
984
+ 'javascript+genshi']
985
+ alias_filenames = ['*.js']
986
+ mimetypes = ['application/x-javascript+genshi',
987
+ 'text/x-javascript+genshi',
988
+ 'text/javascript+genshi']
989
+
990
+ def __init__(self, **options):
991
+ super(JavascriptGenshiLexer, self).__init__(JavascriptLexer,
992
+ GenshiTextLexer,
993
+ **options)
994
+
995
+ def analyse_text(text):
996
+ return GenshiLexer.analyse_text(text) - 0.05
997
+
998
+
999
+ class CssGenshiLexer(DelegatingLexer):
1000
+ """
1001
+ A lexer that highlights CSS definitions in genshi text templates.
1002
+ """
1003
+
1004
+ name = 'CSS+Genshi Text'
1005
+ aliases = ['css+genshitext', 'css+genshi']
1006
+ alias_filenames = ['*.css']
1007
+ mimetypes = ['text/css+genshi']
1008
+
1009
+ def __init__(self, **options):
1010
+ super(CssGenshiLexer, self).__init__(CssLexer, GenshiTextLexer,
1011
+ **options)
1012
+
1013
+ def analyse_text(text):
1014
+ return GenshiLexer.analyse_text(text) - 0.05
1015
+
1016
+
1017
+ class RhtmlLexer(DelegatingLexer):
1018
+ """
1019
+ Subclass of the ERB lexer that highlights the unlexed data with the
1020
+ html lexer.
1021
+
1022
+ Nested Javascript and CSS is highlighted too.
1023
+ """
1024
+
1025
+ name = 'RHTML'
1026
+ aliases = ['rhtml', 'html+erb', 'html+ruby']
1027
+ filenames = ['*.rhtml']
1028
+ alias_filenames = ['*.html', '*.htm', '*.xhtml']
1029
+ mimetypes = ['text/html+ruby']
1030
+
1031
+ def __init__(self, **options):
1032
+ super(RhtmlLexer, self).__init__(HtmlLexer, ErbLexer, **options)
1033
+
1034
+ def analyse_text(text):
1035
+ rv = ErbLexer.analyse_text(text) - 0.01
1036
+ if html_doctype_matches(text):
1037
+ # one more than the XmlErbLexer returns
1038
+ rv += 0.5
1039
+ return rv
1040
+
1041
+
1042
+ class XmlErbLexer(DelegatingLexer):
1043
+ """
1044
+ Subclass of `ErbLexer` which highlights data outside preprocessor
1045
+ directives with the `XmlLexer`.
1046
+ """
1047
+
1048
+ name = 'XML+Ruby'
1049
+ aliases = ['xml+erb', 'xml+ruby']
1050
+ alias_filenames = ['*.xml']
1051
+ mimetypes = ['application/xml+ruby']
1052
+
1053
+ def __init__(self, **options):
1054
+ super(XmlErbLexer, self).__init__(XmlLexer, ErbLexer, **options)
1055
+
1056
+ def analyse_text(text):
1057
+ rv = ErbLexer.analyse_text(text) - 0.01
1058
+ if looks_like_xml(text):
1059
+ rv += 0.4
1060
+ return rv
1061
+
1062
+
1063
+ class CssErbLexer(DelegatingLexer):
1064
+ """
1065
+ Subclass of `ErbLexer` which highlights unlexed data with the `CssLexer`.
1066
+ """
1067
+
1068
+ name = 'CSS+Ruby'
1069
+ aliases = ['css+erb', 'css+ruby']
1070
+ alias_filenames = ['*.css']
1071
+ mimetypes = ['text/css+ruby']
1072
+
1073
+ def __init__(self, **options):
1074
+ super(CssErbLexer, self).__init__(CssLexer, ErbLexer, **options)
1075
+
1076
+ def analyse_text(text):
1077
+ return ErbLexer.analyse_text(text) - 0.05
1078
+
1079
+
1080
+ class JavascriptErbLexer(DelegatingLexer):
1081
+ """
1082
+ Subclass of `ErbLexer` which highlights unlexed data with the
1083
+ `JavascriptLexer`.
1084
+ """
1085
+
1086
+ name = 'JavaScript+Ruby'
1087
+ aliases = ['js+erb', 'javascript+erb', 'js+ruby', 'javascript+ruby']
1088
+ alias_filenames = ['*.js']
1089
+ mimetypes = ['application/x-javascript+ruby',
1090
+ 'text/x-javascript+ruby',
1091
+ 'text/javascript+ruby']
1092
+
1093
+ def __init__(self, **options):
1094
+ super(JavascriptErbLexer, self).__init__(JavascriptLexer, ErbLexer,
1095
+ **options)
1096
+
1097
+ def analyse_text(text):
1098
+ return ErbLexer.analyse_text(text) - 0.05
1099
+
1100
+
1101
+ class HtmlPhpLexer(DelegatingLexer):
1102
+ """
1103
+ Subclass of `PhpLexer` that highlights unhandled data with the `HtmlLexer`.
1104
+
1105
+ Nested Javascript and CSS is highlighted too.
1106
+ """
1107
+
1108
+ name = 'HTML+PHP'
1109
+ aliases = ['html+php']
1110
+ filenames = ['*.phtml']
1111
+ alias_filenames = ['*.php', '*.html', '*.htm', '*.xhtml',
1112
+ '*.php[345]']
1113
+ mimetypes = ['application/x-php',
1114
+ 'application/x-httpd-php', 'application/x-httpd-php3',
1115
+ 'application/x-httpd-php4', 'application/x-httpd-php5']
1116
+
1117
+ def __init__(self, **options):
1118
+ super(HtmlPhpLexer, self).__init__(HtmlLexer, PhpLexer, **options)
1119
+
1120
+ def analyse_text(text):
1121
+ rv = PhpLexer.analyse_text(text) - 0.01
1122
+ if html_doctype_matches(text):
1123
+ rv += 0.5
1124
+ return rv
1125
+
1126
+
1127
+ class XmlPhpLexer(DelegatingLexer):
1128
+ """
1129
+ Subclass of `PhpLexer` that highlights unhandled data with the `XmlLexer`.
1130
+ """
1131
+
1132
+ name = 'XML+PHP'
1133
+ aliases = ['xml+php']
1134
+ alias_filenames = ['*.xml', '*.php', '*.php[345]']
1135
+ mimetypes = ['application/xml+php']
1136
+
1137
+ def __init__(self, **options):
1138
+ super(XmlPhpLexer, self).__init__(XmlLexer, PhpLexer, **options)
1139
+
1140
+ def analyse_text(text):
1141
+ rv = PhpLexer.analyse_text(text) - 0.01
1142
+ if looks_like_xml(text):
1143
+ rv += 0.4
1144
+ return rv
1145
+
1146
+
1147
+ class CssPhpLexer(DelegatingLexer):
1148
+ """
1149
+ Subclass of `PhpLexer` which highlights unmatched data with the `CssLexer`.
1150
+ """
1151
+
1152
+ name = 'CSS+PHP'
1153
+ aliases = ['css+php']
1154
+ alias_filenames = ['*.css']
1155
+ mimetypes = ['text/css+php']
1156
+
1157
+ def __init__(self, **options):
1158
+ super(CssPhpLexer, self).__init__(CssLexer, PhpLexer, **options)
1159
+
1160
+ def analyse_text(text):
1161
+ return PhpLexer.analyse_text(text) - 0.05
1162
+
1163
+
1164
+ class JavascriptPhpLexer(DelegatingLexer):
1165
+ """
1166
+ Subclass of `PhpLexer` which highlights unmatched data with the
1167
+ `JavascriptLexer`.
1168
+ """
1169
+
1170
+ name = 'JavaScript+PHP'
1171
+ aliases = ['js+php', 'javascript+php']
1172
+ alias_filenames = ['*.js']
1173
+ mimetypes = ['application/x-javascript+php',
1174
+ 'text/x-javascript+php',
1175
+ 'text/javascript+php']
1176
+
1177
+ def __init__(self, **options):
1178
+ super(JavascriptPhpLexer, self).__init__(JavascriptLexer, PhpLexer,
1179
+ **options)
1180
+
1181
+ def analyse_text(text):
1182
+ return PhpLexer.analyse_text(text)
1183
+
1184
+
1185
+ class HtmlSmartyLexer(DelegatingLexer):
1186
+ """
1187
+ Subclass of the `SmartyLexer` that highlights unlexed data with the
1188
+ `HtmlLexer`.
1189
+
1190
+ Nested Javascript and CSS is highlighted too.
1191
+ """
1192
+
1193
+ name = 'HTML+Smarty'
1194
+ aliases = ['html+smarty']
1195
+ alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.tpl']
1196
+ mimetypes = ['text/html+smarty']
1197
+
1198
+ def __init__(self, **options):
1199
+ super(HtmlSmartyLexer, self).__init__(HtmlLexer, SmartyLexer, **options)
1200
+
1201
+ def analyse_text(text):
1202
+ rv = SmartyLexer.analyse_text(text) - 0.01
1203
+ if html_doctype_matches(text):
1204
+ rv += 0.5
1205
+ return rv
1206
+
1207
+
1208
+ class XmlSmartyLexer(DelegatingLexer):
1209
+ """
1210
+ Subclass of the `SmartyLexer` that highlights unlexed data with the
1211
+ `XmlLexer`.
1212
+ """
1213
+
1214
+ name = 'XML+Smarty'
1215
+ aliases = ['xml+smarty']
1216
+ alias_filenames = ['*.xml', '*.tpl']
1217
+ mimetypes = ['application/xml+smarty']
1218
+
1219
+ def __init__(self, **options):
1220
+ super(XmlSmartyLexer, self).__init__(XmlLexer, SmartyLexer, **options)
1221
+
1222
+ def analyse_text(text):
1223
+ rv = SmartyLexer.analyse_text(text) - 0.01
1224
+ if looks_like_xml(text):
1225
+ rv += 0.4
1226
+ return rv
1227
+
1228
+
1229
+ class CssSmartyLexer(DelegatingLexer):
1230
+ """
1231
+ Subclass of the `SmartyLexer` that highlights unlexed data with the
1232
+ `CssLexer`.
1233
+ """
1234
+
1235
+ name = 'CSS+Smarty'
1236
+ aliases = ['css+smarty']
1237
+ alias_filenames = ['*.css', '*.tpl']
1238
+ mimetypes = ['text/css+smarty']
1239
+
1240
+ def __init__(self, **options):
1241
+ super(CssSmartyLexer, self).__init__(CssLexer, SmartyLexer, **options)
1242
+
1243
+ def analyse_text(text):
1244
+ return SmartyLexer.analyse_text(text) - 0.05
1245
+
1246
+
1247
+ class JavascriptSmartyLexer(DelegatingLexer):
1248
+ """
1249
+ Subclass of the `SmartyLexer` that highlights unlexed data with the
1250
+ `JavascriptLexer`.
1251
+ """
1252
+
1253
+ name = 'JavaScript+Smarty'
1254
+ aliases = ['js+smarty', 'javascript+smarty']
1255
+ alias_filenames = ['*.js', '*.tpl']
1256
+ mimetypes = ['application/x-javascript+smarty',
1257
+ 'text/x-javascript+smarty',
1258
+ 'text/javascript+smarty']
1259
+
1260
+ def __init__(self, **options):
1261
+ super(JavascriptSmartyLexer, self).__init__(JavascriptLexer, SmartyLexer,
1262
+ **options)
1263
+
1264
+ def analyse_text(text):
1265
+ return SmartyLexer.analyse_text(text) - 0.05
1266
+
1267
+
1268
+ class HtmlDjangoLexer(DelegatingLexer):
1269
+ """
1270
+ Subclass of the `DjangoLexer` that highlights unlexed data with the
1271
+ `HtmlLexer`.
1272
+
1273
+ Nested Javascript and CSS is highlighted too.
1274
+ """
1275
+
1276
+ name = 'HTML+Django/Jinja'
1277
+ aliases = ['html+django', 'html+jinja', 'htmldjango']
1278
+ alias_filenames = ['*.html', '*.htm', '*.xhtml']
1279
+ mimetypes = ['text/html+django', 'text/html+jinja']
1280
+
1281
+ def __init__(self, **options):
1282
+ super(HtmlDjangoLexer, self).__init__(HtmlLexer, DjangoLexer, **options)
1283
+
1284
+ def analyse_text(text):
1285
+ rv = DjangoLexer.analyse_text(text) - 0.01
1286
+ if html_doctype_matches(text):
1287
+ rv += 0.5
1288
+ return rv
1289
+
1290
+
1291
+ class XmlDjangoLexer(DelegatingLexer):
1292
+ """
1293
+ Subclass of the `DjangoLexer` that highlights unlexed data with the
1294
+ `XmlLexer`.
1295
+ """
1296
+
1297
+ name = 'XML+Django/Jinja'
1298
+ aliases = ['xml+django', 'xml+jinja']
1299
+ alias_filenames = ['*.xml']
1300
+ mimetypes = ['application/xml+django', 'application/xml+jinja']
1301
+
1302
+ def __init__(self, **options):
1303
+ super(XmlDjangoLexer, self).__init__(XmlLexer, DjangoLexer, **options)
1304
+
1305
+ def analyse_text(text):
1306
+ rv = DjangoLexer.analyse_text(text) - 0.01
1307
+ if looks_like_xml(text):
1308
+ rv += 0.4
1309
+ return rv
1310
+
1311
+
1312
+ class CssDjangoLexer(DelegatingLexer):
1313
+ """
1314
+ Subclass of the `DjangoLexer` that highlights unlexed data with the
1315
+ `CssLexer`.
1316
+ """
1317
+
1318
+ name = 'CSS+Django/Jinja'
1319
+ aliases = ['css+django', 'css+jinja']
1320
+ alias_filenames = ['*.css']
1321
+ mimetypes = ['text/css+django', 'text/css+jinja']
1322
+
1323
+ def __init__(self, **options):
1324
+ super(CssDjangoLexer, self).__init__(CssLexer, DjangoLexer, **options)
1325
+
1326
+ def analyse_text(text):
1327
+ return DjangoLexer.analyse_text(text) - 0.05
1328
+
1329
+
1330
+ class JavascriptDjangoLexer(DelegatingLexer):
1331
+ """
1332
+ Subclass of the `DjangoLexer` that highlights unlexed data with the
1333
+ `JavascriptLexer`.
1334
+ """
1335
+
1336
+ name = 'JavaScript+Django/Jinja'
1337
+ aliases = ['js+django', 'javascript+django',
1338
+ 'js+jinja', 'javascript+jinja']
1339
+ alias_filenames = ['*.js']
1340
+ mimetypes = ['application/x-javascript+django',
1341
+ 'application/x-javascript+jinja',
1342
+ 'text/x-javascript+django',
1343
+ 'text/x-javascript+jinja',
1344
+ 'text/javascript+django',
1345
+ 'text/javascript+jinja']
1346
+
1347
+ def __init__(self, **options):
1348
+ super(JavascriptDjangoLexer, self).__init__(JavascriptLexer, DjangoLexer,
1349
+ **options)
1350
+
1351
+ def analyse_text(text):
1352
+ return DjangoLexer.analyse_text(text) - 0.05
1353
+
1354
+
1355
+ class JspRootLexer(RegexLexer):
1356
+ """
1357
+ Base for the `JspLexer`. Yields `Token.Other` for area outside of
1358
+ JSP tags.
1359
+
1360
+ .. versionadded:: 0.7
1361
+ """
1362
+
1363
+ tokens = {
1364
+ 'root': [
1365
+ (r'<%\S?', Keyword, 'sec'),
1366
+ # FIXME: I want to make these keywords but still parse attributes.
1367
+ (r'</?jsp:(forward|getProperty|include|plugin|setProperty|useBean).*?>',
1368
+ Keyword),
1369
+ (r'[^<]+', Other),
1370
+ (r'<', Other),
1371
+ ],
1372
+ 'sec': [
1373
+ (r'%>', Keyword, '#pop'),
1374
+ # note: '\w\W' != '.' without DOTALL.
1375
+ (r'[\w\W]+?(?=%>|\Z)', using(JavaLexer)),
1376
+ ],
1377
+ }
1378
+
1379
+
1380
+ class JspLexer(DelegatingLexer):
1381
+ """
1382
+ Lexer for Java Server Pages.
1383
+
1384
+ .. versionadded:: 0.7
1385
+ """
1386
+ name = 'Java Server Page'
1387
+ aliases = ['jsp']
1388
+ filenames = ['*.jsp']
1389
+ mimetypes = ['application/x-jsp']
1390
+
1391
+ def __init__(self, **options):
1392
+ super(JspLexer, self).__init__(XmlLexer, JspRootLexer, **options)
1393
+
1394
+ def analyse_text(text):
1395
+ rv = JavaLexer.analyse_text(text) - 0.01
1396
+ if looks_like_xml(text):
1397
+ rv += 0.4
1398
+ if '<%' in text and '%>' in text:
1399
+ rv += 0.1
1400
+ return rv
1401
+
1402
+
1403
+ class EvoqueLexer(RegexLexer):
1404
+ """
1405
+ For files using the Evoque templating system.
1406
+
1407
+ .. versionadded:: 1.1
1408
+ """
1409
+ name = 'Evoque'
1410
+ aliases = ['evoque']
1411
+ filenames = ['*.evoque']
1412
+ mimetypes = ['application/x-evoque']
1413
+
1414
+ flags = re.DOTALL
1415
+
1416
+ tokens = {
1417
+ 'root': [
1418
+ (r'[^#$]+', Other),
1419
+ (r'#\[', Comment.Multiline, 'comment'),
1420
+ (r'\$\$', Other),
1421
+ # svn keywords
1422
+ (r'\$\w+:[^$\n]*\$', Comment.Multiline),
1423
+ # directives: begin, end
1424
+ (r'(\$)(begin|end)(\{(%)?)(.*?)((?(4)%)\})',
1425
+ bygroups(Punctuation, Name.Builtin, Punctuation, None,
1426
+ String, Punctuation)),
1427
+ # directives: evoque, overlay
1428
+ # see doc for handling first name arg: /directives/evoque/
1429
+ # + minor inconsistency: the "name" in e.g. $overlay{name=site_base}
1430
+ # should be using(PythonLexer), not passed out as String
1431
+ (r'(\$)(evoque|overlay)(\{(%)?)(\s*[#\w\-"\'.]+[^=,%}]+?)?'
1432
+ r'(.*?)((?(4)%)\})',
1433
+ bygroups(Punctuation, Name.Builtin, Punctuation, None,
1434
+ String, using(PythonLexer), Punctuation)),
1435
+ # directives: if, for, prefer, test
1436
+ (r'(\$)(\w+)(\{(%)?)(.*?)((?(4)%)\})',
1437
+ bygroups(Punctuation, Name.Builtin, Punctuation, None,
1438
+ using(PythonLexer), Punctuation)),
1439
+ # directive clauses (no {} expression)
1440
+ (r'(\$)(else|rof|fi)', bygroups(Punctuation, Name.Builtin)),
1441
+ # expressions
1442
+ (r'(\$\{(%)?)(.*?)((!)(.*?))?((?(2)%)\})',
1443
+ bygroups(Punctuation, None, using(PythonLexer),
1444
+ Name.Builtin, None, None, Punctuation)),
1445
+ (r'#', Other),
1446
+ ],
1447
+ 'comment': [
1448
+ (r'[^\]#]', Comment.Multiline),
1449
+ (r'#\[', Comment.Multiline, '#push'),
1450
+ (r'\]#', Comment.Multiline, '#pop'),
1451
+ (r'[\]#]', Comment.Multiline)
1452
+ ],
1453
+ }
1454
+
1455
+
1456
+ class EvoqueHtmlLexer(DelegatingLexer):
1457
+ """
1458
+ Subclass of the `EvoqueLexer` that highlights unlexed data with the
1459
+ `HtmlLexer`.
1460
+
1461
+ .. versionadded:: 1.1
1462
+ """
1463
+ name = 'HTML+Evoque'
1464
+ aliases = ['html+evoque']
1465
+ filenames = ['*.html']
1466
+ mimetypes = ['text/html+evoque']
1467
+
1468
+ def __init__(self, **options):
1469
+ super(EvoqueHtmlLexer, self).__init__(HtmlLexer, EvoqueLexer,
1470
+ **options)
1471
+
1472
+
1473
+ class EvoqueXmlLexer(DelegatingLexer):
1474
+ """
1475
+ Subclass of the `EvoqueLexer` that highlights unlexed data with the
1476
+ `XmlLexer`.
1477
+
1478
+ .. versionadded:: 1.1
1479
+ """
1480
+ name = 'XML+Evoque'
1481
+ aliases = ['xml+evoque']
1482
+ filenames = ['*.xml']
1483
+ mimetypes = ['application/xml+evoque']
1484
+
1485
+ def __init__(self, **options):
1486
+ super(EvoqueXmlLexer, self).__init__(XmlLexer, EvoqueLexer,
1487
+ **options)
1488
+
1489
+
1490
+ class ColdfusionLexer(RegexLexer):
1491
+ """
1492
+ Coldfusion statements
1493
+ """
1494
+ name = 'cfstatement'
1495
+ aliases = ['cfs']
1496
+ filenames = []
1497
+ mimetypes = []
1498
+ flags = re.IGNORECASE
1499
+
1500
+ tokens = {
1501
+ 'root': [
1502
+ (r'//.*?\n', Comment.Single),
1503
+ (r'/\*(?:.|\n)*?\*/', Comment.Multiline),
1504
+ (r'\+\+|--', Operator),
1505
+ (r'[-+*/^&=!]', Operator),
1506
+ (r'<=|>=|<|>|==', Operator),
1507
+ (r'mod\b', Operator),
1508
+ (r'(eq|lt|gt|lte|gte|not|is|and|or)\b', Operator),
1509
+ (r'\|\||&&', Operator),
1510
+ (r'\?', Operator),
1511
+ (r'"', String.Double, 'string'),
1512
+ # There is a special rule for allowing html in single quoted
1513
+ # strings, evidently.
1514
+ (r"'.*?'", String.Single),
1515
+ (r'\d+', Number),
1516
+ (r'(if|else|len|var|xml|default|break|switch|component|property|function|do|'
1517
+ r'try|catch|in|continue|for|return|while|required|any|array|binary|boolean|'
1518
+ r'component|date|guid|numeric|query|string|struct|uuid|case)\b', Keyword),
1519
+ (r'(true|false|null)\b', Keyword.Constant),
1520
+ (r'(application|session|client|cookie|super|this|variables|arguments)\b',
1521
+ Name.Constant),
1522
+ (r'([a-z_$][\w.]*)(\s*)(\()',
1523
+ bygroups(Name.Function, Text, Punctuation)),
1524
+ (r'[a-z_$][\w.]*', Name.Variable),
1525
+ (r'[()\[\]{};:,.\\]', Punctuation),
1526
+ (r'\s+', Text),
1527
+ ],
1528
+ 'string': [
1529
+ (r'""', String.Double),
1530
+ (r'#.+?#', String.Interp),
1531
+ (r'[^"#]+', String.Double),
1532
+ (r'#', String.Double),
1533
+ (r'"', String.Double, '#pop'),
1534
+ ],
1535
+ }
1536
+
1537
+
1538
+ class ColdfusionMarkupLexer(RegexLexer):
1539
+ """
1540
+ Coldfusion markup only
1541
+ """
1542
+ name = 'Coldfusion'
1543
+ aliases = ['cf']
1544
+ filenames = []
1545
+ mimetypes = []
1546
+
1547
+ tokens = {
1548
+ 'root': [
1549
+ (r'[^<]+', Other),
1550
+ include('tags'),
1551
+ (r'<[^<>]*', Other),
1552
+ ],
1553
+ 'tags': [
1554
+ (r'<!---', Comment.Multiline, 'cfcomment'),
1555
+ (r'(?s)<!--.*?-->', Comment),
1556
+ (r'<cfoutput.*?>', Name.Builtin, 'cfoutput'),
1557
+ (r'(?s)(<cfscript.*?>)(.+?)(</cfscript.*?>)',
1558
+ bygroups(Name.Builtin, using(ColdfusionLexer), Name.Builtin)),
1559
+ # negative lookbehind is for strings with embedded >
1560
+ (r'(?s)(</?cf(?:component|include|if|else|elseif|loop|return|'
1561
+ r'dbinfo|dump|abort|location|invoke|throw|file|savecontent|'
1562
+ r'mailpart|mail|header|content|zip|image|lock|argument|try|'
1563
+ r'catch|break|directory|http|set|function|param)\b)(.*?)((?<!\\)>)',
1564
+ bygroups(Name.Builtin, using(ColdfusionLexer), Name.Builtin)),
1565
+ ],
1566
+ 'cfoutput': [
1567
+ (r'[^#<]+', Other),
1568
+ (r'(#)(.*?)(#)', bygroups(Punctuation, using(ColdfusionLexer),
1569
+ Punctuation)),
1570
+ # (r'<cfoutput.*?>', Name.Builtin, '#push'),
1571
+ (r'</cfoutput.*?>', Name.Builtin, '#pop'),
1572
+ include('tags'),
1573
+ (r'(?s)<[^<>]*', Other),
1574
+ (r'#', Other),
1575
+ ],
1576
+ 'cfcomment': [
1577
+ (r'<!---', Comment.Multiline, '#push'),
1578
+ (r'--->', Comment.Multiline, '#pop'),
1579
+ (r'([^<-]|<(?!!---)|-(?!-->))+', Comment.Multiline),
1580
+ ],
1581
+ }
1582
+
1583
+
1584
+ class ColdfusionHtmlLexer(DelegatingLexer):
1585
+ """
1586
+ Coldfusion markup in html
1587
+ """
1588
+ name = 'Coldfusion HTML'
1589
+ aliases = ['cfm']
1590
+ filenames = ['*.cfm', '*.cfml']
1591
+ mimetypes = ['application/x-coldfusion']
1592
+
1593
+ def __init__(self, **options):
1594
+ super(ColdfusionHtmlLexer, self).__init__(HtmlLexer, ColdfusionMarkupLexer,
1595
+ **options)
1596
+
1597
+
1598
+ class ColdfusionCFCLexer(DelegatingLexer):
1599
+ """
1600
+ Coldfusion markup/script components
1601
+
1602
+ .. versionadded:: 2.0
1603
+ """
1604
+ name = 'Coldfusion CFC'
1605
+ aliases = ['cfc']
1606
+ filenames = ['*.cfc']
1607
+ mimetypes = []
1608
+
1609
+ def __init__(self, **options):
1610
+ super(ColdfusionCFCLexer, self).__init__(ColdfusionHtmlLexer, ColdfusionLexer,
1611
+ **options)
1612
+
1613
+
1614
+ class SspLexer(DelegatingLexer):
1615
+ """
1616
+ Lexer for Scalate Server Pages.
1617
+
1618
+ .. versionadded:: 1.4
1619
+ """
1620
+ name = 'Scalate Server Page'
1621
+ aliases = ['ssp']
1622
+ filenames = ['*.ssp']
1623
+ mimetypes = ['application/x-ssp']
1624
+
1625
+ def __init__(self, **options):
1626
+ super(SspLexer, self).__init__(XmlLexer, JspRootLexer, **options)
1627
+
1628
+ def analyse_text(text):
1629
+ rv = 0.0
1630
+ if re.search('val \w+\s*:', text):
1631
+ rv += 0.6
1632
+ if looks_like_xml(text):
1633
+ rv += 0.2
1634
+ if '<%' in text and '%>' in text:
1635
+ rv += 0.1
1636
+ return rv
1637
+
1638
+
1639
+ class TeaTemplateRootLexer(RegexLexer):
1640
+ """
1641
+ Base for the `TeaTemplateLexer`. Yields `Token.Other` for area outside of
1642
+ code blocks.
1643
+
1644
+ .. versionadded:: 1.5
1645
+ """
1646
+
1647
+ tokens = {
1648
+ 'root': [
1649
+ (r'<%\S?', Keyword, 'sec'),
1650
+ (r'[^<]+', Other),
1651
+ (r'<', Other),
1652
+ ],
1653
+ 'sec': [
1654
+ (r'%>', Keyword, '#pop'),
1655
+ # note: '\w\W' != '.' without DOTALL.
1656
+ (r'[\w\W]+?(?=%>|\Z)', using(TeaLangLexer)),
1657
+ ],
1658
+ }
1659
+
1660
+
1661
+ class TeaTemplateLexer(DelegatingLexer):
1662
+ """
1663
+ Lexer for `Tea Templates <http://teatrove.org/>`_.
1664
+
1665
+ .. versionadded:: 1.5
1666
+ """
1667
+ name = 'Tea'
1668
+ aliases = ['tea']
1669
+ filenames = ['*.tea']
1670
+ mimetypes = ['text/x-tea']
1671
+
1672
+ def __init__(self, **options):
1673
+ super(TeaTemplateLexer, self).__init__(XmlLexer,
1674
+ TeaTemplateRootLexer, **options)
1675
+
1676
+ def analyse_text(text):
1677
+ rv = TeaLangLexer.analyse_text(text) - 0.01
1678
+ if looks_like_xml(text):
1679
+ rv += 0.4
1680
+ if '<%' in text and '%>' in text:
1681
+ rv += 0.1
1682
+ return rv
1683
+
1684
+
1685
+ class LassoHtmlLexer(DelegatingLexer):
1686
+ """
1687
+ Subclass of the `LassoLexer` which highlights unhandled data with the
1688
+ `HtmlLexer`.
1689
+
1690
+ Nested JavaScript and CSS is also highlighted.
1691
+
1692
+ .. versionadded:: 1.6
1693
+ """
1694
+
1695
+ name = 'HTML+Lasso'
1696
+ aliases = ['html+lasso']
1697
+ alias_filenames = ['*.html', '*.htm', '*.xhtml', '*.lasso', '*.lasso[89]',
1698
+ '*.incl', '*.inc', '*.las']
1699
+ mimetypes = ['text/html+lasso',
1700
+ 'application/x-httpd-lasso',
1701
+ 'application/x-httpd-lasso[89]']
1702
+
1703
+ def __init__(self, **options):
1704
+ super(LassoHtmlLexer, self).__init__(HtmlLexer, LassoLexer, **options)
1705
+
1706
+ def analyse_text(text):
1707
+ rv = LassoLexer.analyse_text(text) - 0.01
1708
+ if html_doctype_matches(text): # same as HTML lexer
1709
+ rv += 0.5
1710
+ return rv
1711
+
1712
+
1713
+ class LassoXmlLexer(DelegatingLexer):
1714
+ """
1715
+ Subclass of the `LassoLexer` which highlights unhandled data with the
1716
+ `XmlLexer`.
1717
+
1718
+ .. versionadded:: 1.6
1719
+ """
1720
+
1721
+ name = 'XML+Lasso'
1722
+ aliases = ['xml+lasso']
1723
+ alias_filenames = ['*.xml', '*.lasso', '*.lasso[89]',
1724
+ '*.incl', '*.inc', '*.las']
1725
+ mimetypes = ['application/xml+lasso']
1726
+
1727
+ def __init__(self, **options):
1728
+ super(LassoXmlLexer, self).__init__(XmlLexer, LassoLexer, **options)
1729
+
1730
+ def analyse_text(text):
1731
+ rv = LassoLexer.analyse_text(text) - 0.01
1732
+ if looks_like_xml(text):
1733
+ rv += 0.4
1734
+ return rv
1735
+
1736
+
1737
+ class LassoCssLexer(DelegatingLexer):
1738
+ """
1739
+ Subclass of the `LassoLexer` which highlights unhandled data with the
1740
+ `CssLexer`.
1741
+
1742
+ .. versionadded:: 1.6
1743
+ """
1744
+
1745
+ name = 'CSS+Lasso'
1746
+ aliases = ['css+lasso']
1747
+ alias_filenames = ['*.css']
1748
+ mimetypes = ['text/css+lasso']
1749
+
1750
+ def __init__(self, **options):
1751
+ options['requiredelimiters'] = True
1752
+ super(LassoCssLexer, self).__init__(CssLexer, LassoLexer, **options)
1753
+
1754
+ def analyse_text(text):
1755
+ rv = LassoLexer.analyse_text(text) - 0.05
1756
+ if re.search(r'\w+:.+?;', text):
1757
+ rv += 0.1
1758
+ if 'padding:' in text:
1759
+ rv += 0.1
1760
+ return rv
1761
+
1762
+
1763
+ class LassoJavascriptLexer(DelegatingLexer):
1764
+ """
1765
+ Subclass of the `LassoLexer` which highlights unhandled data with the
1766
+ `JavascriptLexer`.
1767
+
1768
+ .. versionadded:: 1.6
1769
+ """
1770
+
1771
+ name = 'JavaScript+Lasso'
1772
+ aliases = ['js+lasso', 'javascript+lasso']
1773
+ alias_filenames = ['*.js']
1774
+ mimetypes = ['application/x-javascript+lasso',
1775
+ 'text/x-javascript+lasso',
1776
+ 'text/javascript+lasso']
1777
+
1778
+ def __init__(self, **options):
1779
+ options['requiredelimiters'] = True
1780
+ super(LassoJavascriptLexer, self).__init__(JavascriptLexer, LassoLexer,
1781
+ **options)
1782
+
1783
+ def analyse_text(text):
1784
+ rv = LassoLexer.analyse_text(text) - 0.05
1785
+ return rv
1786
+
1787
+
1788
+ class HandlebarsLexer(RegexLexer):
1789
+ """
1790
+ Generic `handlebars <http://handlebarsjs.com/>` template lexer.
1791
+
1792
+ Highlights only the Handlebars template tags (stuff between `{{` and `}}`).
1793
+ Everything else is left for a delegating lexer.
1794
+
1795
+ .. versionadded:: 2.0
1796
+ """
1797
+
1798
+ name = "Handlebars"
1799
+ aliases = ['handlebars']
1800
+
1801
+ tokens = {
1802
+ 'root': [
1803
+ (r'[^{]+', Other),
1804
+
1805
+ (r'\{\{!.*\}\}', Comment),
1806
+
1807
+ (r'(\{\{\{)(\s*)', bygroups(Comment.Special, Text), 'tag'),
1808
+ (r'(\{\{)(\s*)', bygroups(Comment.Preproc, Text), 'tag'),
1809
+ ],
1810
+
1811
+ 'tag': [
1812
+ (r'\s+', Text),
1813
+ (r'\}\}\}', Comment.Special, '#pop'),
1814
+ (r'\}\}', Comment.Preproc, '#pop'),
1815
+
1816
+ # Handlebars
1817
+ (r'([#/]*)(each|if|unless|else|with|log|in(line)?)', bygroups(Keyword,
1818
+ Keyword)),
1819
+ (r'#\*inline', Keyword),
1820
+
1821
+ # General {{#block}}
1822
+ (r'([#/])([\w-]+)', bygroups(Name.Function, Name.Function)),
1823
+
1824
+ # {{opt=something}}
1825
+ (r'([\w-]+)(=)', bygroups(Name.Attribute, Operator)),
1826
+
1827
+ # Partials {{> ...}}
1828
+ (r'(>)(\s*)(@partial-block)', bygroups(Keyword, Text, Keyword)),
1829
+ (r'(#?>)(\s*)([\w-]+)', bygroups(Keyword, Text, Name.Variable)),
1830
+ (r'(>)(\s*)(\()', bygroups(Keyword, Text, Punctuation),
1831
+ 'dynamic-partial'),
1832
+
1833
+ include('generic'),
1834
+ ],
1835
+ 'dynamic-partial': [
1836
+ (r'\s+', Text),
1837
+ (r'\)', Punctuation, '#pop'),
1838
+
1839
+ (r'(lookup)(\s+)(\.|this)(\s+)', bygroups(Keyword, Text,
1840
+ Name.Variable, Text)),
1841
+ (r'(lookup)(\s+)(\S+)', bygroups(Keyword, Text,
1842
+ using(this, state='variable'))),
1843
+ (r'[\w-]+', Name.Function),
1844
+
1845
+ include('generic'),
1846
+ ],
1847
+ 'variable': [
1848
+ (r'[a-zA-Z][\w-]*', Name.Variable),
1849
+ (r'\.[\w-]+', Name.Variable),
1850
+ (r'(this\/|\.\/|(\.\.\/)+)[\w-]+', Name.Variable),
1851
+ ],
1852
+ 'generic': [
1853
+ include('variable'),
1854
+
1855
+ # borrowed from DjangoLexer
1856
+ (r':?"(\\\\|\\"|[^"])*"', String.Double),
1857
+ (r":?'(\\\\|\\'|[^'])*'", String.Single),
1858
+ (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
1859
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
1860
+ ]
1861
+ }
1862
+
1863
+
1864
+ class HandlebarsHtmlLexer(DelegatingLexer):
1865
+ """
1866
+ Subclass of the `HandlebarsLexer` that highlights unlexed data with the
1867
+ `HtmlLexer`.
1868
+
1869
+ .. versionadded:: 2.0
1870
+ """
1871
+
1872
+ name = "HTML+Handlebars"
1873
+ aliases = ["html+handlebars"]
1874
+ filenames = ['*.handlebars', '*.hbs']
1875
+ mimetypes = ['text/html+handlebars', 'text/x-handlebars-template']
1876
+
1877
+ def __init__(self, **options):
1878
+ super(HandlebarsHtmlLexer, self).__init__(HtmlLexer, HandlebarsLexer, **options)
1879
+
1880
+
1881
+ class YamlJinjaLexer(DelegatingLexer):
1882
+ """
1883
+ Subclass of the `DjangoLexer` that highlights unlexed data with the
1884
+ `YamlLexer`.
1885
+
1886
+ Commonly used in Saltstack salt states.
1887
+
1888
+ .. versionadded:: 2.0
1889
+ """
1890
+
1891
+ name = 'YAML+Jinja'
1892
+ aliases = ['yaml+jinja', 'salt', 'sls']
1893
+ filenames = ['*.sls']
1894
+ mimetypes = ['text/x-yaml+jinja', 'text/x-sls']
1895
+
1896
+ def __init__(self, **options):
1897
+ super(YamlJinjaLexer, self).__init__(YamlLexer, DjangoLexer, **options)
1898
+
1899
+
1900
+ class LiquidLexer(RegexLexer):
1901
+ """
1902
+ Lexer for `Liquid templates
1903
+ <http://www.rubydoc.info/github/Shopify/liquid>`_.
1904
+
1905
+ .. versionadded:: 2.0
1906
+ """
1907
+ name = 'liquid'
1908
+ aliases = ['liquid']
1909
+ filenames = ['*.liquid']
1910
+
1911
+ tokens = {
1912
+ 'root': [
1913
+ (r'[^{]+', Text),
1914
+ # tags and block tags
1915
+ (r'(\{%)(\s*)', bygroups(Punctuation, Whitespace), 'tag-or-block'),
1916
+ # output tags
1917
+ (r'(\{\{)(\s*)([^\s}]+)',
1918
+ bygroups(Punctuation, Whitespace, using(this, state = 'generic')),
1919
+ 'output'),
1920
+ (r'\{', Text)
1921
+ ],
1922
+
1923
+ 'tag-or-block': [
1924
+ # builtin logic blocks
1925
+ (r'(if|unless|elsif|case)(?=\s+)', Keyword.Reserved, 'condition'),
1926
+ (r'(when)(\s+)', bygroups(Keyword.Reserved, Whitespace),
1927
+ combined('end-of-block', 'whitespace', 'generic')),
1928
+ (r'(else)(\s*)(%\})',
1929
+ bygroups(Keyword.Reserved, Whitespace, Punctuation), '#pop'),
1930
+
1931
+ # other builtin blocks
1932
+ (r'(capture)(\s+)([^\s%]+)(\s*)(%\})',
1933
+ bygroups(Name.Tag, Whitespace, using(this, state = 'variable'),
1934
+ Whitespace, Punctuation), '#pop'),
1935
+ (r'(comment)(\s*)(%\})',
1936
+ bygroups(Name.Tag, Whitespace, Punctuation), 'comment'),
1937
+ (r'(raw)(\s*)(%\})',
1938
+ bygroups(Name.Tag, Whitespace, Punctuation), 'raw'),
1939
+
1940
+ # end of block
1941
+ (r'(end(case|unless|if))(\s*)(%\})',
1942
+ bygroups(Keyword.Reserved, None, Whitespace, Punctuation), '#pop'),
1943
+ (r'(end([^\s%]+))(\s*)(%\})',
1944
+ bygroups(Name.Tag, None, Whitespace, Punctuation), '#pop'),
1945
+
1946
+ # builtin tags (assign and include are handled together with usual tags)
1947
+ (r'(cycle)(\s+)(?:([^\s:]*)(:))?(\s*)',
1948
+ bygroups(Name.Tag, Whitespace,
1949
+ using(this, state='generic'), Punctuation, Whitespace),
1950
+ 'variable-tag-markup'),
1951
+
1952
+ # other tags or blocks
1953
+ (r'([^\s%]+)(\s*)', bygroups(Name.Tag, Whitespace), 'tag-markup')
1954
+ ],
1955
+
1956
+ 'output': [
1957
+ include('whitespace'),
1958
+ ('\}\}', Punctuation, '#pop'), # end of output
1959
+
1960
+ (r'\|', Punctuation, 'filters')
1961
+ ],
1962
+
1963
+ 'filters': [
1964
+ include('whitespace'),
1965
+ (r'\}\}', Punctuation, ('#pop', '#pop')), # end of filters and output
1966
+
1967
+ (r'([^\s|:]+)(:?)(\s*)',
1968
+ bygroups(Name.Function, Punctuation, Whitespace), 'filter-markup')
1969
+ ],
1970
+
1971
+ 'filter-markup': [
1972
+ (r'\|', Punctuation, '#pop'),
1973
+ include('end-of-tag'),
1974
+ include('default-param-markup')
1975
+ ],
1976
+
1977
+ 'condition': [
1978
+ include('end-of-block'),
1979
+ include('whitespace'),
1980
+
1981
+ (r'([^\s=!><]+)(\s*)([=!><]=?)(\s*)(\S+)(\s*)(%\})',
1982
+ bygroups(using(this, state = 'generic'), Whitespace, Operator,
1983
+ Whitespace, using(this, state = 'generic'), Whitespace,
1984
+ Punctuation)),
1985
+ (r'\b!', Operator),
1986
+ (r'\bnot\b', Operator.Word),
1987
+ (r'([\w.\'"]+)(\s+)(contains)(\s+)([\w.\'"]+)',
1988
+ bygroups(using(this, state = 'generic'), Whitespace, Operator.Word,
1989
+ Whitespace, using(this, state = 'generic'))),
1990
+
1991
+ include('generic'),
1992
+ include('whitespace')
1993
+ ],
1994
+
1995
+ 'generic-value': [
1996
+ include('generic'),
1997
+ include('end-at-whitespace')
1998
+ ],
1999
+
2000
+ 'operator': [
2001
+ (r'(\s*)((=|!|>|<)=?)(\s*)',
2002
+ bygroups(Whitespace, Operator, None, Whitespace), '#pop'),
2003
+ (r'(\s*)(\bcontains\b)(\s*)',
2004
+ bygroups(Whitespace, Operator.Word, Whitespace), '#pop'),
2005
+ ],
2006
+
2007
+ 'end-of-tag': [
2008
+ (r'\}\}', Punctuation, '#pop')
2009
+ ],
2010
+
2011
+ 'end-of-block': [
2012
+ (r'%\}', Punctuation, ('#pop', '#pop'))
2013
+ ],
2014
+
2015
+ 'end-at-whitespace': [
2016
+ (r'\s+', Whitespace, '#pop')
2017
+ ],
2018
+
2019
+ # states for unknown markup
2020
+ 'param-markup': [
2021
+ include('whitespace'),
2022
+ # params with colons or equals
2023
+ (r'([^\s=:]+)(\s*)(=|:)',
2024
+ bygroups(Name.Attribute, Whitespace, Operator)),
2025
+ # explicit variables
2026
+ (r'(\{\{)(\s*)([^\s}])(\s*)(\}\})',
2027
+ bygroups(Punctuation, Whitespace, using(this, state = 'variable'),
2028
+ Whitespace, Punctuation)),
2029
+
2030
+ include('string'),
2031
+ include('number'),
2032
+ include('keyword'),
2033
+ (r',', Punctuation)
2034
+ ],
2035
+
2036
+ 'default-param-markup': [
2037
+ include('param-markup'),
2038
+ (r'.', Text) # fallback for switches / variables / un-quoted strings / ...
2039
+ ],
2040
+
2041
+ 'variable-param-markup': [
2042
+ include('param-markup'),
2043
+ include('variable'),
2044
+ (r'.', Text) # fallback
2045
+ ],
2046
+
2047
+ 'tag-markup': [
2048
+ (r'%\}', Punctuation, ('#pop', '#pop')), # end of tag
2049
+ include('default-param-markup')
2050
+ ],
2051
+
2052
+ 'variable-tag-markup': [
2053
+ (r'%\}', Punctuation, ('#pop', '#pop')), # end of tag
2054
+ include('variable-param-markup')
2055
+ ],
2056
+
2057
+ # states for different values types
2058
+ 'keyword': [
2059
+ (r'\b(false|true)\b', Keyword.Constant)
2060
+ ],
2061
+
2062
+ 'variable': [
2063
+ (r'[a-zA-Z_]\w*', Name.Variable),
2064
+ (r'(?<=\w)\.(?=\w)', Punctuation)
2065
+ ],
2066
+
2067
+ 'string': [
2068
+ (r"'[^']*'", String.Single),
2069
+ (r'"[^"]*"', String.Double)
2070
+ ],
2071
+
2072
+ 'number': [
2073
+ (r'\d+\.\d+', Number.Float),
2074
+ (r'\d+', Number.Integer)
2075
+ ],
2076
+
2077
+ 'generic': [ # decides for variable, string, keyword or number
2078
+ include('keyword'),
2079
+ include('string'),
2080
+ include('number'),
2081
+ include('variable')
2082
+ ],
2083
+
2084
+ 'whitespace': [
2085
+ (r'[ \t]+', Whitespace)
2086
+ ],
2087
+
2088
+ # states for builtin blocks
2089
+ 'comment': [
2090
+ (r'(\{%)(\s*)(endcomment)(\s*)(%\})',
2091
+ bygroups(Punctuation, Whitespace, Name.Tag, Whitespace,
2092
+ Punctuation), ('#pop', '#pop')),
2093
+ (r'.', Comment)
2094
+ ],
2095
+
2096
+ 'raw': [
2097
+ (r'[^{]+', Text),
2098
+ (r'(\{%)(\s*)(endraw)(\s*)(%\})',
2099
+ bygroups(Punctuation, Whitespace, Name.Tag, Whitespace,
2100
+ Punctuation), '#pop'),
2101
+ (r'\{', Text)
2102
+ ],
2103
+ }
2104
+
2105
+
2106
+ class TwigLexer(RegexLexer):
2107
+ """
2108
+ `Twig <http://twig.sensiolabs.org/>`_ template lexer.
2109
+
2110
+ It just highlights Twig code between the preprocessor directives,
2111
+ other data is left untouched by the lexer.
2112
+
2113
+ .. versionadded:: 2.0
2114
+ """
2115
+
2116
+ name = 'Twig'
2117
+ aliases = ['twig']
2118
+ mimetypes = ['application/x-twig']
2119
+
2120
+ flags = re.M | re.S
2121
+
2122
+ # Note that a backslash is included in the following two patterns
2123
+ # PHP uses a backslash as a namespace separator
2124
+ _ident_char = r'[\\\w-]|[^\x00-\x7f]'
2125
+ _ident_begin = r'(?:[\\_a-z]|[^\x00-\x7f])'
2126
+ _ident_end = r'(?:' + _ident_char + ')*'
2127
+ _ident_inner = _ident_begin + _ident_end
2128
+
2129
+ tokens = {
2130
+ 'root': [
2131
+ (r'[^{]+', Other),
2132
+ (r'\{\{', Comment.Preproc, 'var'),
2133
+ # twig comments
2134
+ (r'\{\#.*?\#\}', Comment),
2135
+ # raw twig blocks
2136
+ (r'(\{%)(-?\s*)(raw)(\s*-?)(%\})(.*?)'
2137
+ r'(\{%)(-?\s*)(endraw)(\s*-?)(%\})',
2138
+ bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc,
2139
+ Other, Comment.Preproc, Text, Keyword, Text,
2140
+ Comment.Preproc)),
2141
+ (r'(\{%)(-?\s*)(verbatim)(\s*-?)(%\})(.*?)'
2142
+ r'(\{%)(-?\s*)(endverbatim)(\s*-?)(%\})',
2143
+ bygroups(Comment.Preproc, Text, Keyword, Text, Comment.Preproc,
2144
+ Other, Comment.Preproc, Text, Keyword, Text,
2145
+ Comment.Preproc)),
2146
+ # filter blocks
2147
+ (r'(\{%%)(-?\s*)(filter)(\s+)(%s)' % _ident_inner,
2148
+ bygroups(Comment.Preproc, Text, Keyword, Text, Name.Function),
2149
+ 'tag'),
2150
+ (r'(\{%)(-?\s*)([a-zA-Z_]\w*)',
2151
+ bygroups(Comment.Preproc, Text, Keyword), 'tag'),
2152
+ (r'\{', Other),
2153
+ ],
2154
+ 'varnames': [
2155
+ (r'(\|)(\s*)(%s)' % _ident_inner,
2156
+ bygroups(Operator, Text, Name.Function)),
2157
+ (r'(is)(\s+)(not)?(\s*)(%s)' % _ident_inner,
2158
+ bygroups(Keyword, Text, Keyword, Text, Name.Function)),
2159
+ (r'(?i)(true|false|none|null)\b', Keyword.Pseudo),
2160
+ (r'(in|not|and|b-and|or|b-or|b-xor|is'
2161
+ r'if|elseif|else|import'
2162
+ r'constant|defined|divisibleby|empty|even|iterable|odd|sameas'
2163
+ r'matches|starts\s+with|ends\s+with)\b',
2164
+ Keyword),
2165
+ (r'(loop|block|parent)\b', Name.Builtin),
2166
+ (_ident_inner, Name.Variable),
2167
+ (r'\.' + _ident_inner, Name.Variable),
2168
+ (r'\.[0-9]+', Number),
2169
+ (r':?"(\\\\|\\"|[^"])*"', String.Double),
2170
+ (r":?'(\\\\|\\'|[^'])*'", String.Single),
2171
+ (r'([{}()\[\]+\-*/,:~%]|\.\.|\?|:|\*\*|\/\/|!=|[><=]=?)', Operator),
2172
+ (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
2173
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
2174
+ ],
2175
+ 'var': [
2176
+ (r'\s+', Text),
2177
+ (r'(-?)(\}\})', bygroups(Text, Comment.Preproc), '#pop'),
2178
+ include('varnames')
2179
+ ],
2180
+ 'tag': [
2181
+ (r'\s+', Text),
2182
+ (r'(-?)(%\})', bygroups(Text, Comment.Preproc), '#pop'),
2183
+ include('varnames'),
2184
+ (r'.', Punctuation),
2185
+ ],
2186
+ }
2187
+
2188
+
2189
+ class TwigHtmlLexer(DelegatingLexer):
2190
+ """
2191
+ Subclass of the `TwigLexer` that highlights unlexed data with the
2192
+ `HtmlLexer`.
2193
+
2194
+ .. versionadded:: 2.0
2195
+ """
2196
+
2197
+ name = "HTML+Twig"
2198
+ aliases = ["html+twig"]
2199
+ filenames = ['*.twig']
2200
+ mimetypes = ['text/html+twig']
2201
+
2202
+ def __init__(self, **options):
2203
+ super(TwigHtmlLexer, self).__init__(HtmlLexer, TwigLexer, **options)
2204
+
2205
+
2206
+ class Angular2Lexer(RegexLexer):
2207
+ """
2208
+ Generic
2209
+ `angular2 <http://victorsavkin.com/post/119943127151/angular-2-template-syntax>`_
2210
+ template lexer.
2211
+
2212
+ Highlights only the Angular template tags (stuff between `{{` and `}}` and
2213
+ special attributes: '(event)=', '[property]=', '[(twoWayBinding)]=').
2214
+ Everything else is left for a delegating lexer.
2215
+
2216
+ .. versionadded:: 2.1
2217
+ """
2218
+
2219
+ name = "Angular2"
2220
+ aliases = ['ng2']
2221
+
2222
+ tokens = {
2223
+ 'root': [
2224
+ (r'[^{([*#]+', Other),
2225
+
2226
+ # {{meal.name}}
2227
+ (r'(\{\{)(\s*)', bygroups(Comment.Preproc, Text), 'ngExpression'),
2228
+
2229
+ # (click)="deleteOrder()"; [value]="test"; [(twoWayTest)]="foo.bar"
2230
+ (r'([([]+)([\w:.-]+)([\])]+)(\s*)(=)(\s*)',
2231
+ bygroups(Punctuation, Name.Attribute, Punctuation, Text, Operator, Text),
2232
+ 'attr'),
2233
+ (r'([([]+)([\w:.-]+)([\])]+)(\s*)',
2234
+ bygroups(Punctuation, Name.Attribute, Punctuation, Text)),
2235
+
2236
+ # *ngIf="..."; #f="ngForm"
2237
+ (r'([*#])([\w:.-]+)(\s*)(=)(\s*)',
2238
+ bygroups(Punctuation, Name.Attribute, Punctuation, Operator), 'attr'),
2239
+ (r'([*#])([\w:.-]+)(\s*)',
2240
+ bygroups(Punctuation, Name.Attribute, Punctuation)),
2241
+ ],
2242
+
2243
+ 'ngExpression': [
2244
+ (r'\s+(\|\s+)?', Text),
2245
+ (r'\}\}', Comment.Preproc, '#pop'),
2246
+
2247
+ # Literals
2248
+ (r':?(true|false)', String.Boolean),
2249
+ (r':?"(\\\\|\\"|[^"])*"', String.Double),
2250
+ (r":?'(\\\\|\\'|[^'])*'", String.Single),
2251
+ (r"[0-9](\.[0-9]*)?(eE[+-][0-9])?[flFLdD]?|"
2252
+ r"0[xX][0-9a-fA-F]+[Ll]?", Number),
2253
+
2254
+ # Variabletext
2255
+ (r'[a-zA-Z][\w-]*(\(.*\))?', Name.Variable),
2256
+ (r'\.[\w-]+(\(.*\))?', Name.Variable),
2257
+
2258
+ # inline If
2259
+ (r'(\?)(\s*)([^}\s]+)(\s*)(:)(\s*)([^}\s]+)(\s*)',
2260
+ bygroups(Operator, Text, String, Text, Operator, Text, String, Text)),
2261
+ ],
2262
+ 'attr': [
2263
+ ('".*?"', String, '#pop'),
2264
+ ("'.*?'", String, '#pop'),
2265
+ (r'[^\s>]+', String, '#pop'),
2266
+ ],
2267
+ }
2268
+
2269
+
2270
+ class Angular2HtmlLexer(DelegatingLexer):
2271
+ """
2272
+ Subclass of the `Angular2Lexer` that highlights unlexed data with the
2273
+ `HtmlLexer`.
2274
+
2275
+ .. versionadded:: 2.0
2276
+ """
2277
+
2278
+ name = "HTML + Angular2"
2279
+ aliases = ["html+ng2"]
2280
+ filenames = ['*.ng2']
2281
+
2282
+ def __init__(self, **options):
2283
+ super(Angular2HtmlLexer, self).__init__(HtmlLexer, Angular2Lexer, **options)