ripgrep

Options:

For example *.py or **/templates/**/*.html or datasette/** or !setup.py

dogsheep-beta/dogsheep_beta/__init__.py

57      from datasette.utils import path_with_removed_args, path_with_replaced_args
58  
59      config = datasette.plugin_config("dogsheep-beta") or {}
60      database_name = config.get("database") or datasette.get_database().name
61      dogsheep_beta_config_file = config["config_file"]

datasette-tiles/datasette_tiles/utils.py

32  
33  async def tiles_stack_database_order(datasette):
34      config = datasette.plugin_config("datasette-tiles") or {}
35      stack_order = config.get("tiles-stack-order")
36      if not stack_order:

datasette-sentry/datasette_sentry.py

6   @hookimpl
7   def asgi_wrapper(datasette):
8       config = datasette.plugin_config("datasette-sentry") or {}
9       dsn = config.get("dsn")
10      if dsn is not None:

datasette-seaborn/datasette_seaborn/__init__.py

28      }
29  
30      plugin_config = datasette.plugin_config("datasette-seaborn") or {}
31      render_time_limit = plugin_config.get("render_time_limit") or DEFAULT_TIME_LIMIT
32  

datasette-render-timestamps/datasette_render_timestamps/__init__.py

18  def render_cell(value, column, table, database, datasette):
19      config = (
20          datasette.plugin_config(
21              "datasette-render-timestamps", database=database, table=table
22          )

datasette-ripgrep/README.md

15  
16  - [with.\*AsyncClient](https://ripgrep.datasette.io/-/ripgrep?pattern=with.*AsyncClient) - regular expression search for `with.*AsyncClient`
17  - [.plugin_config, literal=on](https://ripgrep.datasette.io/-/ripgrep?pattern=.plugin_config\(&literal=on) - a non-regular expression search for `.plugin_config(`
18  - [with.\*AsyncClient glob=datasette/\*\*](https://ripgrep.datasette.io/-/ripgrep?pattern=with.*AsyncClient&glob=datasette%2F%2A%2A) - search for that pattern only within the `datasette/` top folder
19  - ["sqlite-utils\[">\] glob=setup.py](https://ripgrep.datasette.io/-/ripgrep?pattern=%22sqlite-utils%5B%22%3E%5D&glob=setup.py) - a regular expression search for packages that depend on either `sqlite-utils` or `sqlite-utils>=some-version`

datasette-ripgrep/datasette_ripgrep/__init__.py

81      globs = [g.strip() for g in request.args.getlist("glob") if g.strip()]
82  
83      config = datasette.plugin_config("datasette-ripgrep") or {}
84      time_limit = config.get("time_limit") or 1.0
85      max_lines = config.get("max_lines") or 2000
138 async def view_file(request, datasette):
139     await check_permission(request, datasette)
140     config = datasette.plugin_config("datasette-ripgrep") or {}
141     subpath = urllib.parse.unquote(request.url_vars["subpath"])
142     path = config.get("path")

datasette-render-markdown/datasette_render_markdown/__init__.py

13      should_convert = False
14      config = (
15          datasette.plugin_config(
16              "datasette-render-markdown", database=database, table=table
17          )

datasette-render-html/datasette_render_html.py

5   @hookimpl
6   def render_cell(value, column, table, database, datasette):
7       config = datasette.plugin_config(
8           "datasette-render-html", database=database, table=table
9       )

datasette-render-images/datasette_render_images.py

11      size_limit = DEFAULT_SIZE_LIMIT
12      if datasette:
13          plugin_config = datasette.plugin_config("datasette-render-images") or {}
14          size_limit = plugin_config.get("size_limit") or DEFAULT_SIZE_LIMIT
15      # Only act on byte columns

datasette-remote-metadata/datasette_remote_metadata/__init__.py

12      # when it hits time limit. If the time limit is hit it will still
13      # perform the update once the request has completed
14      config = datasette.plugin_config("datasette-remote-metadata") or {}
15      url = config.get("url")
16      if not url:
59  def asgi_wrapper(datasette):
60      # Refresh stale (over X seconds old) remote metadata on every request
61      config = datasette.plugin_config("datasette-remote-metadata") or {}
62      ttl = config.get("ttl") or 30
63  

datasette-permissions-sql/datasette_permissions_sql/__init__.py

20                  value = json.dumps(value, default=repr)
21              params["actor_{}".format(key)] = value
22          for rule in datasette.plugin_config("datasette-permissions-sql") or []:
23              sql = rule["sql"]
24              rule_action = rule.get("action")

datasette-mask-columns/datasette_mask_columns/__init__.py

9               return sqlite3.SQLITE_OK
10          masks = (
11              datasette.plugin_config("datasette-mask-columns", database=database) or {}
12          )
13          columns_to_mask = masks.get(table) or None
29  @hookimpl()
30  def render_cell(column, table, database, datasette):
31      masks = datasette.plugin_config("datasette-mask-columns", database=database) or {}
32      columns_to_mask = masks.get(table) or set()
33      if column in columns_to_mask:

datasette-media/datasette_media/__init__.py

22  async def serve_media(datasette, request, send):
23      global transform_executor
24      plugin_config = datasette.plugin_config("datasette-media") or {}
25      pool_size = plugin_config.get("transform_threads") or 4
26      if transform_executor is None:

datasette-leaflet-geojson/datasette_leaflet_geojson/__init__.py

61  def extra_body_script(datasette, database, table):
62      config = (
63          datasette.plugin_config(
64              "datasette-leaflet-geojson", database=database, table=table
65          )

datasette-insert/datasette_insert/__init__.py

84      if action != "insert:all":
85          return None
86      plugin_config = datasette.plugin_config("datasette-insert") or {}
87      if "allow" in plugin_config:
88          return actor_matches_allow(actor, plugin_config["allow"])

datasette-init/datasette_init/__init__.py

6   def startup(datasette):
7       async def inner():
8           config = datasette.plugin_config("datasette-init")
9           if not config:
10              return

datasette-indieauth/datasette_indieauth/__init__.py

230     if action != "view-instance":
231         return None
232     plugin_config = datasette.plugin_config("datasette-indieauth") or {}
233     if plugin_config.get("restrict_access") is None:
234         return None

datasette-graphql/datasette_graphql/utils.py

234         schema=graphene.Schema(
235             query=Query,
236             auto_camelcase=(datasette.plugin_config("datasette-graphql") or {}).get(
237                 "auto_camelcase", False
238             ),
358     fks_by_column = {fk.column: fk for fk in meta.foreign_keys}
359 
360     table_plugin_config = datasette.plugin_config(
361         "datasette-graphql", database=db.name, table=table
362     )

datasette-graphql/datasette_graphql/__init__.py

96          )
97  
98      config = datasette.plugin_config("datasette-graphql") or {}
99      context = {
100         "time_started": time.monotonic(),
191 def startup(datasette):
192     # Validate configuration
193     config = datasette.plugin_config("datasette-graphql") or {}
194     if "databases" in config:
195         for database_name in config["databases"].keys():

datasette-edit-templates/datasette_edit_templates/__init__.py

50  
51  def get_database(datasette):
52      plugin_config = datasette.plugin_config("datasette-edit-templates") or {}
53      return datasette.get_database(plugin_config.get("database"))
54  

datasette-cors/datasette_cors.py

5   @hookimpl
6   def asgi_wrapper(datasette):
7       config = datasette.plugin_config("datasette-cors") or {}
8       allow_all = config.get("allow_all") or False
9       hosts = config.get("hosts") or []

datasette-configure-asgi/datasette_configure_asgi.py

6   def asgi_wrapper(datasette):
7       def wrap_with_classes(app):
8           configs = datasette.plugin_config("datasette-configure-asgi") or []
9           for config in configs:
10              module_path, class_name = config["class"].rsplit(".", 1)

datasette-cluster-map/datasette_cluster_map/__init__.py

30          return []
31      config = (
32          datasette.plugin_config("datasette-cluster-map", database=database, table=table)
33          or {}
34      )
76      columns = [column.lower() for column in columns]
77      config = (
78          datasette.plugin_config("datasette-cluster-map", database=database, table=table)
79          or {}
80      )

datasette-block-robots/datasette_block_robots/__init__.py

4   
5   def robots_txt(datasette):
6       config = datasette.plugin_config("datasette-block-robots") or {}
7       literal = config.get("literal")
8       disallow = []
32  @hookimpl
33  def startup(datasette):
34      config = datasette.plugin_config("datasette-block-robots") or {}
35      assert not (
36          config.get("disallow") and config.get("literal")

datasette-block/datasette_block/__init__.py

5   @hookimpl
6   def asgi_wrapper(datasette):
7       config = datasette.plugin_config("datasette-block") or {}
8       prefixes = config.get("prefixes") or []
9   

datasette-auth-tokens/datasette_auth_tokens/__init__.py

6   def actor_from_request(datasette, request):
7       async def inner():
8           config = datasette.plugin_config("datasette-auth-tokens") or {}
9           allowed_tokens = config.get("tokens") or []
10          authorization = request.headers.get("authorization")

datasette-auth-passwords/datasette_auth_passwords/utils.py

29  
30  def scope_has_valid_authorization(scope, datasette):
31      config = datasette.plugin_config("datasette-auth-passwords") or {}
32      accounts = {
33          key.split("_password_hash")[0]: value

datasette-auth-passwords/datasette_auth_passwords/__init__.py

23  
24  async def password_login(request, datasette):
25      config = datasette.plugin_config("datasette-auth-passwords") or {}
26      accounts = {
27          key.split("_password_hash")[0]: value
64  @hookimpl
65  def asgi_wrapper(datasette):
66      config = datasette.plugin_config("datasette-auth-passwords") or {}
67      if not config.get("http_basic_auth"):
68          return lambda asgi: asgi

datasette-auth-existing-cookies/datasette_auth_existing_cookies/__init__.py

10  @hookimpl(trylast=True)
11  def asgi_wrapper(datasette):
12      config = datasette.plugin_config("datasette-auth-existing-cookies") or {}
13      api_url = config["api_url"]
14      auth_redirect_url = config["auth_redirect_url"]

datasette-auth-github/datasette_auth_github/views.py

15  
16  async def github_auth_start(datasette):
17      config = datasette.plugin_config("datasette-auth-github")
18      verify_config(config)
19      if config.get("load_teams") or config.get("load_orgs"):
39  
40  async def github_auth_callback(datasette, request, scope, receive, send):
41      config = datasette.plugin_config("datasette-auth-github")
42      verify_config(config)
43      if not request.args.get("code"):

datasette-atom/datasette_atom/__init__.py

51      if query_name:
52          # Check allow_unsafe_html_in_canned_queries
53          plugin_config = datasette.plugin_config("datasette-atom")
54          if plugin_config:
55              allow_unsafe_html_in_canned_queries = plugin_config.get(

datasette/tests/test_plugins.py

52      )
53      assert [
54          "database=fixtures, datasette.plugin_config(\"name-of-plugin\")={'depth': 'root'}"
55      ] == response.json
56  
197 
198 def test_plugin_config(app_client):
199     assert {"depth": "table"} == app_client.ds.plugin_config(
200         "name-of-plugin", database="fixtures", table="sortable"
201     )
202     assert {"depth": "database"} == app_client.ds.plugin_config(
203         "name-of-plugin", database="fixtures", table="unknown_table"
204     )
205     assert {"depth": "database"} == app_client.ds.plugin_config(
206         "name-of-plugin", database="fixtures"
207     )
208     assert {"depth": "root"} == app_client.ds.plugin_config(
209         "name-of-plugin", database="unknown_database"
210     )
211     assert {"depth": "root"} == app_client.ds.plugin_config("name-of-plugin")
212     assert None is app_client.ds.plugin_config("unknown-plugin")
213 
214 
215 def test_plugin_config_env(app_client):
216     os.environ["FOO_ENV"] = "FROM_ENVIRONMENT"
217     assert {"foo": "FROM_ENVIRONMENT"} == app_client.ds.plugin_config("env-plugin")
218     # Ensure secrets aren't visible in /-/metadata.json
219     metadata = app_client.get("/-/metadata.json")
224 def test_plugin_config_env_from_list(app_client):
225     os.environ["FOO_ENV"] = "FROM_ENVIRONMENT"
226     assert [{"in_a_list": "FROM_ENVIRONMENT"}] == app_client.ds.plugin_config(
227         "env-plugin-list"
228     )
238     with open(TEMP_PLUGIN_SECRET_FILE, "w") as fp:
239         fp.write("FROM_FILE")
240     assert {"foo": "FROM_FILE"} == app_client.ds.plugin_config("file-plugin")
241     # Ensure secrets aren't visible in /-/metadata.json
242     metadata = app_client.get("/-/metadata.json")

datasette/tests/plugins/my_plugin_2.py

173 @hookimpl
174 def register_routes(datasette):
175     config = datasette.plugin_config("register-route-demo")
176     if not config:
177         return

datasette/tests/plugins/my_plugin.py

19  
20      def prepare_connection_args():
21          return 'database={}, datasette.plugin_config("name-of-plugin")={}'.format(
22              database, datasette.plugin_config("name-of-plugin")
23          )
24  
77                      "database": database,
78                      "table": table,
79                      "config": datasette.plugin_config(
80                          "name-of-plugin",
81                          database=database,
106                     "table": table,
107                     "database": database,
108                     "config": datasette.plugin_config(
109                         "name-of-plugin",
110                         database=database,

datasette/docs/writing_plugins.rst

168 When you are writing plugins, you can access plugin configuration like this using the ``datasette plugin_config()`` method. If you know you need plugin configuration for a specific table, you can access it like this::
169 
170     plugin_config = datasette.plugin_config(
171         "datasette-cluster-map", database="sf-trees", table="Street_Tree_List"
172     )

datasette/docs/plugin_hooks.rst

34  
35  ``datasette`` - :ref:`internals_datasette`
36      You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``
37  
38  This hook is called when a new SQLite database connection is created. You can
107 
108 ``datasette`` - :ref:`internals_datasette`
109     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``
110 
111 This hook can return one of three different types:
270 The ``template``, ``database``, ``table`` and ``view_name`` options can be used to return different code depending on which template is being rendered and which database or table are being processed.
271 
272 The ``datasette`` instance is provided primarily so that you can consult any plugin configuration options that may have been set, using the ``datasette.plugin_config(plugin_name)`` method documented above.
273 
274 This function can return a string containing JavaScript, or a dictionary as described below, or a function or awaitable function that returns a string or dictionary.
370 
371 ``datasette`` - :ref:`internals_datasette`
372     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
373 
374 If your hook returns ``None``, it will be ignored. Use this to indicate that your hook is not able to custom render this particular value.
430 
431 ``datasette`` - :ref:`internals_datasette`
432     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``
433 
434 Registers a new output renderer, to output data in a custom format. The hook function should return a dictionary, or a list of dictionaries, of the following shape:
535 
536 ``datasette`` - :ref:`internals_datasette`
537     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``
538 
539 Register additional view functions to execute for specified URL routes.
565 
566 ``datasette`` - :ref:`internals_datasette`
567     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
568 
569 ``request`` - Request object
757     @hookimpl
758     def startup(datasette):
759         config = datasette.plugin_config("my-plugin") or {}
760         assert "required-setting" in config, "my-plugin requires setting required-setting"
761 
800 
801 ``datasette`` - :ref:`internals_datasette`
802     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
803 
804 ``database`` - string
869 
870 ``datasette`` - :ref:`internals_datasette`
871     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
872 
873 ``request`` - object
930 
931 ``datasette`` - :ref:`internals_datasette`
932     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
933 
934 ``actor`` - dictionary
989 
990 ``datasette`` - :ref:`internals_datasette`
991     You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``.
992 
993 :ref:`canned_queries_magic_parameters` can be used to add automatic parameters to :ref:`canned queries <canned_queries>`. This plugin hook allows additional magic parameters to be defined by plugins.
1028
1029``datasette`` - :ref:`internals_datasette`
1030    You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
1031
1032``request`` - object
1071
1072``datasette`` - :ref:`internals_datasette`
1073    You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
1074
1075``actor`` - dictionary or None
1108
1109``datasette`` - :ref:`internals_datasette`
1110    You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
1111
1112``actor`` - dictionary or None
1148
1149``datasette`` - :ref:`internals_datasette`
1150    You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
1151
1152``actor`` - dictionary or None
1169
1170``datasette`` - :ref:`internals_datasette`
1171    You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``, or to execute SQL queries.
1172
1173``scope`` - dictionary
1194
1195``datasette`` - :ref:`internals_datasette`
1196    You can use this to access plugin configuration options via ``datasette.plugin_config(your_plugin_name)``.
1197
1198``actor`` - dictionary or None

datasette/docs/internals.rst

210 .. _datasette_plugin_config:
211 
212 .plugin_config(plugin_name, database=None, table=None)
213 ------------------------------------------------------
214 

big-local-datasette/plugins/token_auth.py

29  @hookimpl(trylast=True)
30  def asgi_wrapper(datasette):
31      config = datasette.plugin_config("token-auth") or {}
32      secret = config.get("secret")
33      auth = config.get("auth")