mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Use f-strings in place of .format()
Code transformed like so:
pip install flynt
flynt .
black .
This commit is contained in:
parent
6fd35be64d
commit
30e64c8d3b
35 changed files with 213 additions and 277 deletions
|
|
@ -19,10 +19,10 @@ class Urls:
|
|||
return self.path("", format=format)
|
||||
|
||||
def static(self, path):
|
||||
return self.path("-/static/{}".format(path))
|
||||
return self.path(f"-/static/{path}")
|
||||
|
||||
def static_plugins(self, plugin, path):
|
||||
return self.path("-/static-plugins/{}/{}".format(plugin, path))
|
||||
return self.path(f"-/static-plugins/{plugin}/{path}")
|
||||
|
||||
def logout(self):
|
||||
return self.path("-/logout")
|
||||
|
|
@ -30,27 +30,25 @@ class Urls:
|
|||
def database(self, database, format=None):
|
||||
db = self.ds.databases[database]
|
||||
if self.ds.config("hash_urls") and db.hash:
|
||||
path = self.path(
|
||||
"{}-{}".format(database, db.hash[:HASH_LENGTH]), format=format
|
||||
)
|
||||
path = self.path(f"{database}-{db.hash[:HASH_LENGTH]}", format=format)
|
||||
else:
|
||||
path = self.path(database, format=format)
|
||||
return path
|
||||
|
||||
def table(self, database, table, format=None):
|
||||
path = "{}/{}".format(self.database(database), urllib.parse.quote_plus(table))
|
||||
path = f"{self.database(database)}/{urllib.parse.quote_plus(table)}"
|
||||
if format is not None:
|
||||
path = path_with_format(path=path, format=format)
|
||||
return PrefixedUrlString(path)
|
||||
|
||||
def query(self, database, query, format=None):
|
||||
path = "{}/{}".format(self.database(database), urllib.parse.quote_plus(query))
|
||||
path = f"{self.database(database)}/{urllib.parse.quote_plus(query)}"
|
||||
if format is not None:
|
||||
path = path_with_format(path=path, format=format)
|
||||
return PrefixedUrlString(path)
|
||||
|
||||
def row(self, database, table, row_path, format=None):
|
||||
path = "{}/{}".format(self.table(database, table), row_path)
|
||||
path = f"{self.table(database, table)}/{row_path}"
|
||||
if format is not None:
|
||||
path = path_with_format(path=path, format=format)
|
||||
return PrefixedUrlString(path)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue