From 995446bc944b2322f3feb707dc7f44e9cbc192be Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Thu, 14 Mar 2024 19:28:04 -0700 Subject: [PATCH] Try to avoid Python 3.13 cog differences --- docs/cli-reference.rst | 36 ++++++++++++++++++------------------ sqlite_utils/cli.py | 12 ++++++------ 2 files changed, 24 insertions(+), 24 deletions(-) diff --git a/docs/cli-reference.rst b/docs/cli-reference.rst index 55517c9..5ecd669 100644 --- a/docs/cli-reference.rst +++ b/docs/cli-reference.rst @@ -603,9 +603,9 @@ See :ref:`cli_convert`. Convert columns using Python code you supply. For example: - sqlite-utils convert my.db mytable mycolumn \ - '"\n".join(textwrap.wrap(value, 10))' \ - --import=textwrap + sqlite-utils convert my.db mytable mycolumn \ + '"\n".join(textwrap.wrap(value, 10))' \ + --import=textwrap "value" is a variable with the column value to be converted. @@ -615,30 +615,30 @@ See :ref:`cli_convert`. r.jsonsplit(value, delimiter=',', type=) - Convert a string like a,b,c into a JSON array ["a", "b", "c"] + Convert a string like a,b,c into a JSON array ["a", "b", "c"] r.parsedate(value, dayfirst=False, yearfirst=False, errors=None) - Parse a date and convert it to ISO date format: yyyy-mm-dd -  - - dayfirst=True: treat xx as the day in xx/yy/zz - - yearfirst=True: treat xx as the year in xx/yy/zz - - errors=r.IGNORE to ignore values that cannot be parsed - - errors=r.SET_NULL to set values that cannot be parsed to null + Parse a date and convert it to ISO date format: yyyy-mm-dd +  + - dayfirst=True: treat xx as the day in xx/yy/zz + - yearfirst=True: treat xx as the year in xx/yy/zz + - errors=r.IGNORE to ignore values that cannot be parsed + - errors=r.SET_NULL to set values that cannot be parsed to null r.parsedatetime(value, dayfirst=False, yearfirst=False, errors=None) - Parse a datetime and convert it to ISO datetime format: yyyy-mm-ddTHH:MM:SS -  - - dayfirst=True: treat xx as the day in xx/yy/zz - - yearfirst=True: treat xx as the year in xx/yy/zz - - errors=r.IGNORE to ignore values that cannot be parsed - - errors=r.SET_NULL to set values that cannot be parsed to null + Parse a datetime and convert it to ISO datetime format: yyyy-mm-ddTHH:MM:SS +  + - dayfirst=True: treat xx as the day in xx/yy/zz + - yearfirst=True: treat xx as the year in xx/yy/zz + - errors=r.IGNORE to ignore values that cannot be parsed + - errors=r.SET_NULL to set values that cannot be parsed to null You can use these recipes like so: - sqlite-utils convert my.db mytable mycolumn \ - 'r.jsonsplit(value, delimiter=":")' + sqlite-utils convert my.db mytable mycolumn \ + 'r.jsonsplit(value, delimiter=":")' Options: --import TEXT Python modules to import diff --git a/sqlite_utils/cli.py b/sqlite_utils/cli.py index 0ab9132..33f661d 100644 --- a/sqlite_utils/cli.py +++ b/sqlite_utils/cli.py @@ -2871,9 +2871,9 @@ def _generate_convert_help(): Convert columns using Python code you supply. For example: \b - sqlite-utils convert my.db mytable mycolumn \\ - '"\\n".join(textwrap.wrap(value, 10))' \\ - --import=textwrap + sqlite-utils convert my.db mytable mycolumn \\ + '"\\n".join(textwrap.wrap(value, 10))' \\ + --import=textwrap "value" is a variable with the column value to be converted. @@ -2892,7 +2892,7 @@ def _generate_convert_help(): for name in recipe_names: fn = getattr(recipes, name) help += "\n\nr.{}{}\n\n\b{}".format( - name, str(inspect.signature(fn)), fn.__doc__.rstrip() + name, str(inspect.signature(fn)), textwrap.dedent(fn.__doc__.rstrip()) ) help += "\n\n" help += textwrap.dedent( @@ -2900,8 +2900,8 @@ def _generate_convert_help(): You can use these recipes like so: \b - sqlite-utils convert my.db mytable mycolumn \\ - 'r.jsonsplit(value, delimiter=":")' + sqlite-utils convert my.db mytable mycolumn \\ + 'r.jsonsplit(value, delimiter=":")' """ ).strip() return help