{"id":30143073,"url":"https://github.com/sabariramc/funcargpreprocessor","last_synced_at":"2025-08-11T06:30:16.075Z","repository":{"id":54768126,"uuid":"292511712","full_name":"sabariramc/funcargpreprocessor","owner":"sabariramc","description":null,"archived":false,"fork":false,"pushed_at":"2021-05-18T12:28:14.000Z","size":103,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-07-24T10:10:42.846Z","etag":null,"topics":["argument-parser","pytohn3"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sabariramc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-09-03T08:28:57.000Z","updated_at":"2021-05-18T12:27:26.000Z","dependencies_parsed_at":"2022-08-14T02:10:54.940Z","dependency_job_id":null,"html_url":"https://github.com/sabariramc/funcargpreprocessor","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/sabariramc/funcargpreprocessor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabariramc%2Ffuncargpreprocessor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabariramc%2Ffuncargpreprocessor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabariramc%2Ffuncargpreprocessor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabariramc%2Ffuncargpreprocessor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sabariramc","download_url":"https://codeload.github.com/sabariramc/funcargpreprocessor/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sabariramc%2Ffuncargpreprocessor/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":269840978,"owners_count":24483755,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-11T02:00:10.019Z","response_time":75,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["argument-parser","pytohn3"],"created_at":"2025-08-11T06:30:10.273Z","updated_at":"2025-08-11T06:30:16.052Z","avatar_url":"https://github.com/sabariramc.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Function Argument Pre-Processor\n\nThis is a abstract library that need to be extended before put actual use.\n\nThe primary use case is to extend it as a `Flask Extenstion` but is open to use with any other environment/framework that needs to deal with http endpoints eg: `AWS Lambda`   \n\n## Implementations\n   [flask_requestpreprocesser](https://github.com/sabariramc/flask_requestpreprocesser)\n   \n## Installation\n\n```bash\n $ pip install funcargpreprocessor\n```\n\nor download the code and run\n\n```bash\n $ python3 setup.py install\n```\n\n## What it does?\n\n - Extraction and transformation of function argument and raise appropriate exceptions\n\n## Example\n - Please refer [testimplementation.py](https://github.com/sabariramc/funcargpreprocessor/blob/master/testimplementation.py) and [fieldtest.py](https://github.com/sabariramc/funcargpreprocessor/blob/master/fieldtest.py) for examples\n \n### Explanation\n\nThe following explanantion uses the example from `test` folder\n\n```python\n\ndef get_current_time():\n    return datetime.now().replace(microsecond=0)\n\ndef get_current_date():\n    return date.today()\n\ndef get_future_date(date_factor=1):\n    def inner_fu():\n        return date.today() + timedelta(date_factor)\n\n    return inner_fu\n\n\nfrom enum import Enum\n\n\nclass Gender(Enum):\n    MALE = \"male\"\n    FEMALE = \"female\"\n    TRANSGENDER = \"transgender\"\n\ndefinition = {\n    \"pageNo\": { #Key name expected from the HTTP endpoint\n            \"data_type\": int # Data type expected   \n            , \"min_val\": 0 # Min validation for the key \n            , \"max_val\": 20 # Max validation for the key\n            , 'alias': 'page_no' # Key for the function argument, to the function the argument will be 'page_no'\n                                 # Need? most of the time the http request are expected json and the keys will be in camelCase\n            , \"default\": 1 # Default value for the field if no value has been passed\n    }\n    , \"start_date\": {\n                \"data_type\": DateArg('%Y-%m-%d') # Expects a date argument in \u003cstr\u003e'YYYY-MM-DD' format or datetime.date object accepts '2020-01-10', datetime.date(2020, 1, 10)  converts,in case of a string argument, to datetime.date(2020, 1, 10) and passes it to the function\n                , \"min_val\": get_current_date # Function can be passed for min value, this function should not take any argument and should return a single value of the same type\n                , \"max_val\": get_future_date(10) # Function can be passed for max value, this function should not take any argument and should return a single value of the same type\n                , \"required\": True # This key is required to be there in the input\n    }\n    , \"id_list\": {\n                \"data_type\": list # Expects list of value\n                , \"nested\": int # The values in the list should be int same rule as `date_type`\n                , \"value_list\": [0, 1, 2, 3] # Accepted values, valid argument ex: [1,2], [1], [2,3,0]\n                                             # Need? Multiselect options\n    }\n    , \"gender\": {\"data_type\": str, \"value_list\": Gender} #Enum can be used for the value list and will be marshalled\n    , \"random_flag\": {\"data_type\": int, \"value_list\": [0,1]} \n    , 'reg_time': {\"data_type\": DateTimeArg('%Y-%m-%d %H:%M:%S'), \n                    \"default\": get_current_time # Function can be passed for default value, this function should not take any argument and should return a single value of the same type\n    }\n    , \"location\": {\"data_type\": list\n        , \"nested\": { # Custom definition for objects in the list\n            \"address_line_1\": {\"data_type\": str, \"required\": True}\n            , \"address_line_2\": {\"data_type\": str\n                                    , \"min_len\": 5 #Mininum length expected for the argument\n                                    , \"max_len\": 10 # Maximum length accepted for the argument\n                                }\n            , \"latitude\": {\"data_type\": DecimalArg(), \"min_val\": Decimal(\"-90\"), \"max_val\": Decimal(\"90\")}\n            , \"longitude\": {\"data_type\": DecimalArg(), \"min_val\": Decimal(\"-180\"), \"max_val\": Decimal(\"180\")}\n            , \"pincode\": {\"data_type\": int, \"required\": True}\n            , \"contact_person\": {\n                    \"data_type\": dict\n                    , \"nested\": {\n                        \"first_name\": {\"data_type\": str, \"required\": True}\n                        , \"last_name\": {\"data_type\": str}\n                        , \"phone_number\": {\n                                    \"data_type\": str\n                                    , \"required\": True\n                                    , \"regex\": r\"[0-9]{10,12}\" # Regular expression validation\n                                    , \"regex_error_message\": \"\u003csome message\u003e\" # Message when the RegEx validation fails \n                                }\n                    }\n            }   \n        }\n    }\n\n}\n\n\n```  \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabariramc%2Ffuncargpreprocessor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsabariramc%2Ffuncargpreprocessor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsabariramc%2Ffuncargpreprocessor/lists"}