im aware of using python script to generate airport data like:
python -c "from faker import Faker; from faker_airtravel import AirTravelProvider; fake = Faker(); fake.add_provider(AirTravelProvider); airports = [fake.airport_name() for _ in range(10)]; print(airports)"
Which returns data as expected:
['Kahului airport', 'Taiyuan Wusu airport', 'Carriel Sur International airport', 'Fukuoka airport', 'Gustavia airport', 'Santa Maria airport', 'Salta airport', 'Tacoma International airport', 'Camilo Daza airport', 'Senador Nilo Coelho airport']
But Im struggling how to generate the same using faker without python, via faker -i command line option:
$ faker -i faker_airtravel airport_name
AttributeError: module 'faker_airtravel' has no attribute 'Provider'
$ faker -i faker_airtravel.AirTravelProvider airport_name
ModuleNotFoundError: No module named 'faker_airtravel.AirTravelProvider'
$ faker -i AirTravelProvider airport_name
ModuleNotFoundError: No module named 'AirTravelProvider'
Google only returns python examples and couldn't find command line example executing faker with -i to add community provider - like the faker_airtravel installed as:
$ pip install faker_airtravel
issuing a
faker -h
Shows option -i to load extra provider(s) but im having hard time understanding how to have it working:
faker -h
usage: faker [-h] [--version] [-v] [-o output] [-l LOCALE] [-r REPEAT] [-s SEP] [--seed SEED] [-i [INCLUDE ...]] [fake] [fake argument ...]
faker version 18.9.0
positional arguments:
fake name of the fake to generate output for (e.g. profile)
fake argument optional arguments to pass to the fake (e.g. the profile fake takes an optional list of comma separated field names as the first argument)
options:
-h, --help show this help message and exit
--version show program's version number and exit
-v, --verbose show INFO logging events instead of CRITICAL, which is the default. These logging events provide insight into localization of specific providers.
-o output redirect output to a file
-l LOCALE, --lang LOCALE
specify the language for a localized provider (e.g. de_DE)
-r REPEAT, --repeat REPEAT
generate the specified number of outputs
-s SEP, --sep SEP use the specified separator after each output
--seed SEED specify a seed for the random generator so that results are repeatable. Also compatible with 'repeat' option
-i [INCLUDE ...], --include [INCLUDE ...]
list of additional custom providers to user, given as the import path of the module containing your Provider class (not the provider class itself)
I would love simply see whats command line needed to generate 10 airport_name's from provider
$ pip install faker_airtravel
I wonder if problem is on getting command line syntaxe or correct namespace, or if its related to how to correctly install the provider.. maybe more needed then simple:
$ pip install faker_airtravel
I suspect my doubt have easy answer tho
The first command you tried,
faker -i faker_airtravel airport_name, should work, but there is a defect on the provider.If
AirTravelProvideron line 8 of the airports.py file is changed to justProvider, it will work.You can test it by cloning the repository, changing it and installing it with
pip install -e .More information here.