diff options
author | Binbin <binloveplay1314@qq.com> | 2022-01-19 22:07:28 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-19 16:07:28 +0200 |
commit | 3720de78c995812d5be5733e39f3854beeaf5757 (patch) | |
tree | abd6926604e571f96df835fc3e0b7fda24f427b2 /utils | |
parent | 68a8d0b46d08cf745bb29f1063fb579fa39581d6 (diff) | |
download | redis-3720de78c995812d5be5733e39f3854beeaf5757.tar.gz |
Fix fcall_ro key spec flags in commands.c (#10145)
In #10122, we modify the key spec flags to `RO` and `ACCESS`.
But forgot to call generate-command-code.py. Also formatted
it to follow the Python PEP8.
Diffstat (limited to 'utils')
-rwxr-xr-x | utils/generate-command-code.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/utils/generate-command-code.py b/utils/generate-command-code.py index 44a43d7cc..e6801f5df 100755 --- a/utils/generate-command-code.py +++ b/utils/generate-command-code.py @@ -59,15 +59,16 @@ RESP3_TYPES = { "null": "RESP3_NULL", } + def get_optional_desc_string(desc, field, force_uppercase=False): v = desc.get(field, None) if v and force_uppercase: v = v.upper() - ret = "\"%s\"" % v if v else "NULL" - return ret.replace("\n", "\\n") + ret = "\"%s\"" % v if v else "NULL" + return ret.replace("\n", "\\n") -# Globals +# Globals subcommands = {} # container_name -> dict(subcommand_name -> Subcommand) - Only subcommands commands = {} # command_name -> Command - Only commands @@ -152,6 +153,7 @@ class Argument(object): Output example: "expiration",ARG_TYPE_ONEOF,NULL,NULL,NULL,CMD_ARG_OPTIONAL,.value.subargs=SET_expiration_Subargs """ + def _flags_code(): s = "" if self.desc.get("optional", False): @@ -245,6 +247,7 @@ class Command(object): Output example: "set","Set the string value of a key","O(1)","1.0.0",CMD_DOC_NONE,NULL,NULL,COMMAND_GROUP_STRING,SET_History,SET_Hints,setCommand,-3,"write denyoom @string",{{"write read",KSPEC_BS_INDEX,.bs.index={1},KSPEC_FK_RANGE,.fk.range={0,1,0}}},.args=SET_Args """ + def _flags_code(): s = "" for flag in self.desc.get("command_flags", []): @@ -372,7 +375,7 @@ srcdir = os.path.abspath(os.path.dirname(os.path.abspath(__file__)) + "/../src") # Create all command objects print("Processing json files...") for filename in glob.glob('%s/commands/*.json' % srcdir): - with open(filename,"r") as f: + with open(filename, "r") as f: try: d = json.load(f) for name, desc in d.items(): @@ -393,7 +396,7 @@ for command in commands.values(): command.subcommands.append(subcommand) print("Generating commands.c...") -with open("%s/commands.c" % srcdir,"w") as f: +with open("%s/commands.c" % srcdir, "w") as f: f.write("/* Automatically generated by %s, do not edit. */\n\n" % os.path.basename(__file__)) f.write("#include \"server.h\"\n") f.write( @@ -420,4 +423,3 @@ with open("%s/commands.c" % srcdir,"w") as f: f.write("};\n") print("All done, exiting.") - |