Package: gila
GilaGila is a python3 layered configuration library based very heavily on theviperconfig library for Go. It is designed to facilitate making12 factorapps as easy as possible using python3.MotivationAfter having used the Viper config library in Go, I became very used to the ease of use and flexibility that it offered. After looking for a library to use in my python projects I was unable to find one that combined all of the very useful features that Viper supports.FeaturesAllow default values to be set for each config keyAutomatically find config files on multiple pathsLoad in environment variables automatically that have a specific prefixSupport most popular config languages:yaml, toml, json, properties files, hcl, dotenvSingleton pattern available for ease of use in most applicationsHierarchical loading for non-ambiguous results.InstallationRequires python 3.6+pip install gilaSimple ExampleMore examples can be found in the examples directoryimportgilafromosimportenviron# Setting default values for keysgila.set_default('host','localhost:8080')gila.set_default('allow_insecure',False)# This will tell Gila to automatically load in ENV vars that start with GILAgila.set_env_prefix('GILA')gila.automatic_env()# This would normally be done outside of program# eg. in docker compose or k8s manifestenviron['GILA_HOST']='localhost:9999'# This is the preferred method of grabbing# the configurations. Other methods exist (all_config, debug)# but this method is the most performant for single# value calls.host=gila.get('host')allow_insecure=gila.get('allow_insecure')"""Output:Host: localhost:9999Insecure allowed: false"""print(f'Host:{host}')print(f'Insecure allowed:{allow_insecure}')Supported Config Filetypesyaml (.yaml, .yml)json (.json)toml (.toml)hcl (.hcl)environment variablesValues will be cast to stringsKeys are cast to lowercase: ENV_VAR ->gila.get('env_var')properties file (.properties, .prop, .props)Values will be cast to stringsdotenv (.env)Values will be cast to stringsNo nested values supportedAdditional HelpCheck out our documentation onReadTheDocsor if you prefer minimum working examples, checkout the directory </examples/> which house a plethora of use cases from simple to more complex configurations.CreditsSteve Franciaspf13for creating the Viper libraryAuthors ofpyyaml,pyhcl, andtomlpackages, as Gila would have been much harder to create and maintain without themMajor differences from ViperCase sensitivity - all keys in Gila are case sensitive, this allows for proper json, yaml, and toml support. ENV keys are not case sensitive unless manually bound.No support for remote config - while I think that supporting consul and etcd is a very nice feature, I think at this moment in time that it is a feature that belongs in a seperate library.No support for command flags - Viper relies pretty heavily onCobracompanionship for command flags. You should choose your own flavour of CLI parser (docopts, argparse, etc) and pair it with this library (check out our examples).Watching for changes in config files - I would very much so like to add this feature, but it is not a feature that I felt was necessary atv1.0.0. If you would like this feature you can thumbs upthe issue, or open a PR with an implementation.