Locale fr_CA

faker.providers.barcode

class faker.providers.barcode.fr_CA.Provider(generator)

Bases: faker.providers.barcode.en_CA.Provider

Implement bank provider for fr_CA locale.

There is no difference from the en_CA implementation.

ean(length=13, prefixes=())

Generate an EAN barcode of the specified length.

The value of length can only be 8 or 13 (default) which will create an EAN-8 or an EAN-13 barcode respectively.

If a value for prefixes is specified, the result will begin with one of the sequences in prefixes.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean(length=13)
...
'6604876475937'
'8242194892418'
'1578156593879'
'7840801609759'
'3513933287112'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean(length=8)
...
'66048763'
'47593824'
'42194897'
'24115780'
'15659385'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean(prefixes=('00', ))
...
'0004876475931'
'0019489241156'
'0065938778407'
'0016097535134'
'0028711587146'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean(prefixes=('45', '49'))
...
'4904876475930'
'4519489241157'
'4965938778406'
'4916097535133'
'4928711587145'
ean13(leading_zero=None, prefixes=())

Generate an EAN-13 barcode.

If leading_zero is True, the leftmost digit of the barcode will be set to 0. If False, the leftmost digit cannot be 0. If None (default), the leftmost digit can be any digit.

If a value for prefixes is specified, the result will begin with one of the sequences in prefixes and will ignore leading_zero.

This method uses the standard barcode provider’s ean13() under the hood with the prefixes argument set to the correct value to attain the behavior described above.

Note

EAN-13 barcode that starts with a zero can be converted to UPC-A by dropping the leading zero. This may cause problems with readers that treat all of these code as UPC-A codes and drop the first digit when reading it.

You can set the argument prefixes ( or leading_zero for convenience) explicitly to avoid or to force the generated barcode to start with a zero. You can also generate actual UPC-A barcode with EnUsBarcodeProvider.upc_a().

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean13()
...
'6604876475937'
'8242194892418'
'1578156593879'
'7840801609759'
'3513933287112'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean13(leading_zero=False)
...
'7048764759386'
'3948924115783'
'7938778408014'
'7975351393329'
'8158714841852'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean13(leading_zero=True)
...
'0604876475933'
'0219489241150'
'0565938778402'
'0016097535134'
'0328711587147'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean13(prefixes=('00', ))
...
'0004876475931'
'0019489241156'
'0065938778407'
'0016097535134'
'0028711587146'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean13(prefixes=('45', '49'))
...
'4904876475930'
'4519489241157'
'4965938778406'
'4916097535133'
'4928711587145'
ean8(prefixes=())

Generate an EAN-8 barcode.

This method uses ean() under the hood with the length argument explicitly set to 8.

If a value for prefixes is specified, the result will begin with one of the sequences in prefixes.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean8()
...
'66048763'
'47593824'
'42194897'
'24115780'
'15659385'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean8(prefixes=('00', ))
...
'00048767'
'00593823'
'00489249'
'00781565'
'00778404'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.ean8(prefixes=('45', '49'))
...
'49048766'
'45593826'
'45489242'
'45781568'
'49778403'
localized_ean(length=13)

Generate a localized EAN barcode of the specified length.

The value of length can only be 8 or 13 (default) which will create an EAN-8 or an EAN-13 barcode respectively.

This method uses the standard barcode provider’s ean() under the hood with the prefixes argument explicitly set to local_prefixes of a localized barcode provider implementation.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean()
...
'0704876475930'
'0719489241155'
'0965938778400'
'7516097535132'
'0728711587145'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean(length=13)
...
'0704876475930'
'0719489241155'
'0965938778400'
'7516097535132'
'0728711587145'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean(length=8)
...
'75048761'
'01593822'
'00489249'
'06781569'
'09778405'
localized_ean13()

Generate a localized EAN-13 barcode.

This method uses localized_ean() under the hood with the length argument explicitly set to 13.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean13()
...
'0704876475930'
'0719489241155'
'0965938778400'
'7516097535132'
'0728711587145'
localized_ean8()

Generate a localized EAN-8 barcode.

This method uses localized_ean() under the hood with the length argument explicitly set to 8.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.localized_ean8()
...
'75048761'
'01593822'
'00489249'
'06781569'
'09778405'
upc_a(upc_ae_mode=False, base=None, number_system_digit=None)

Generate a 12-digit UPC-A barcode.

The value of upc_ae_mode controls how barcodes will be generated. If False (default), barcodes are not guaranteed to have a UPC-E equivalent. In this mode, the method uses EnUsBarcodeProvider.ean13() under the hood, and the values of base and number_system_digit will be ignored.

If upc_ae_mode is True, the resulting barcodes are guaranteed to have a UPC-E equivalent, and the values of base and number_system_digit will be used to control what is generated.

Under this mode, base is expected to have a 6-digit string value. If any other value is supplied, a random 6-digit string will be used instead. As for number_system_digit, the expected value is a 0 or a 1. If any other value is provided, this method will randomly choose from the two.

Important

When upc_ae_mode is enabled, you might encounter instances where different values of base (e.g. '120003' and '120004') produce the same UPC-A barcode. This is normal, and the reason lies within the whole conversion process. To learn more about this and what base and number_system_digit actually represent, please refer to EnUsBarcodeProvider.upc_e().

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_a()
...
'604876475933'
'219489241150'
'565938778402'
'016097535134'
'328711587147'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_a(upc_ae_mode=True, number_system_digit=0)
...
'066048000075'
'064700000593'
'082421000098'
'048100009240'
'015781000057'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_a(upc_ae_mode=True, number_system_digit=1)
...
'166048000072'
'164700000590'
'182421000095'
'148100009247'
'115781000054'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_a(upc_ae_mode=True, base='123456', number_system_digit=0)
...
'012345000065'
'012345000065'
'012345000065'
'012345000065'
'012345000065'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_a(upc_ae_mode=True, base='120003', number_system_digit=0)
...
'012000000003'
'012000000003'
'012000000003'
'012000000003'
'012000000003'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_a(upc_ae_mode=True, base='120004', number_system_digit=0)
...
'012000000003'
'012000000003'
'012000000003'
'012000000003'
'012000000003'
upc_e(base=None, number_system_digit=None, safe_mode=True)

Generate an 8-digit UPC-E barcode.

UPC-E barcodes can be expressed in 6, 7, or 8-digit formats, but this method uses the 8 digit format, since it is trivial to convert to the other two formats. The first digit (starting from the left) is controlled by number_system_digit, and it can only be a 0 or a 1. The last digit is the check digit that is inherited from the UPC-E barcode’s UPC-A equivalent. The middle six digits are collectively referred to as the base (for a lack of a better term).

On that note, this method uses base and number_system_digit to first generate a UPC-A barcode for the check digit, and what happens next depends on the value of safe_mode. The argument safe_mode exists, because there are some UPC-E values that share the same UPC-A equivalent. For example, any UPC-E barcode of the form abc0000d, abc0003d, and abc0004d share the same UPC-A value abc00000000d, but that UPC-A value will only convert to abc0000d because of (a) how UPC-E is just a zero-suppressed version of UPC-A and (b) the rules around the conversion.

If safe_mode is True (default), this method performs another set of conversions to guarantee that the UPC-E barcodes generated can be converted to UPC-A, and that UPC-A barcode can be converted back to the original UPC-E barcode. Using the example above, even if the bases 120003 or 120004 are used, the resulting UPC-E barcode will always use the base 120000.

If safe_mode is False, then the number_system_digit, base, and the computed check digit will just be concatenated together to produce the UPC-E barcode, and attempting to convert the barcode to UPC-A and back again to UPC-E will exhibit the behavior described above.

Examples:
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e()
...
'16604872'
'04759386'
'04219484'
'04115786'
'15659385'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='123456')
...
'11234562'
'11234562'
'01234565'
'11234562'
'11234562'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='123456', number_system_digit=0)
...
'01234565'
'01234565'
'01234565'
'01234565'
'01234565'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='123456', number_system_digit=1)
...
'11234562'
'11234562'
'11234562'
'11234562'
'11234562'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='120000', number_system_digit=0)
...
'01200003'
'01200003'
'01200003'
'01200003'
'01200003'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='120003', number_system_digit=0)
...
'01200003'
'01200003'
'01200003'
'01200003'
'01200003'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='120004', number_system_digit=0)
...
'01200003'
'01200003'
'01200003'
'01200003'
'01200003'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='120000', number_system_digit=0, safe_mode=False)
...
'01200003'
'01200003'
'01200003'
'01200003'
'01200003'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='120003', number_system_digit=0, safe_mode=False)
...
'01200033'
'01200033'
'01200033'
'01200033'
'01200033'
>>> Faker.seed(0)
>>> for _ in range(5):
...     fake.upc_e(base='120004', number_system_digit=0, safe_mode=False)
...
'01200043'
'01200043'
'01200043'
'01200043'
'01200043'