
    li                     n    d dl Z d dlZd dlmZ d dlmZ d dlmZmZ ddlm	Z	 dZ
dZ G d	 d
e	          ZdS )    N)ceil)ascii_uppercase)DictOptional   )BaseProviderTen_GBc            	           e Zd ZU dZd ej        D             Zeeef         e	d<   dZ
ee	d<   dZee	d<   defd	Zdefd
ZdefdZdefdZdefdZddedefdZddededefdZ	 	 	 ddee         dededefdZdS )Providera  Implement default bank provider for Faker.

    .. important::
       Bank codes, account numbers, and other ID's generated by this provider
       are only valid in form, i.e. they conform to some standard/format, are
       of the expected lengths, and have valid checksums (where applicable).
       Results generated that turn out to be valid in real life are purely
       coincidental.

    Sources:

    - https://en.wikipedia.org/wiki/International_Bank_Account_Number
    - https://www.theswiftcodes.com/swift-code-checker/
    c                 N    i | ]"}|t          t          |          d z            #S )7   )strord).0cs     m/var/www/html/Pagina-Ingenieria-Requisitos/venv/lib/python3.11/site-packages/faker/providers/bank/__init__.py
<dictcomp>zProvider.<dictcomp>   s,    QQQQQCFFRK 0 0QQQ    ALPHAz????#############bban_formatGBcountry_codereturnc                 V   |                      dd          }|                     d          }|d| }d |D             }d|d         |d         z   |d	         z   z  d
|d         |d         z   |d
         z   z  z   |d         z   |d         z   }t          |dz            dz  |z
  }| | S )z'Generate an ABA routing transit number.      )minmaxz######02c                 ,    g | ]}t          |          S  )int)r   ns     r   
<listcomp>z Provider.aba.<locals>.<listcomp>)   s    !!!SVV!!!r      r            r      
   )
random_intnumerifyr   )selffed_numrandabad	chk_digits         r   r0   zProvider.aba"   s    //aR/00}}X&&##T## "!S!!!1!qt+,qAaD1Q4K!A$4F/GG!A$NQRSTQUU	R((2-	9	"y"""r   c                     | j         S )z=Generate the bank provider's ISO 3166-1 alpha-2 country code.)r   r-   s    r   bank_countryzProvider.bank_country/   s      r   c                     t          | d          st          d| j        j         d          |                     | j                  S )zGenerate a bank name.bankszThe z provider does not have a 'banks' attribute. Consider contributing to the project and  adding a 'banks' tuple to enable bank name generation.)hasattrAttributeError	__class____name__random_elementr7   r4   s    r   bankzProvider.bank3   s]    tW%% 	 Jt~. J J J  
 ""4:...r   c                 j     t          j        d fd j                  }                     |          S )z,Generate a Basic Bank Account Number (BBAN).z\?c                 8                         t                    S N)r<   r   )xr-   s    r   <lambda>zProvider.bban.<locals>.<lambda>?   s    t':':?'K'K r   )resubr   r,   )r-   temps   ` r   bbanzProvider.bban=   s5    veKKKKTM]^^}}T"""r   c                                                       }| j        z   dz   }t          d                     fd|D                                 }d|dz  z
  }t	          |                              d          } j        |z   |z   S )z5Generate an International Bank Account Number (IBAN).00 c              3   N   K   | ]}j                             ||          V   d S r@   )r   get)r   r   r-   s     r   	<genexpr>z Provider.iban.<locals>.<genexpr>G   s3      AAaTZ^^Aq11AAAAAAr   b   a   r   )rF   r   r"   joinr   zfill)r-   rF   checkcheck_s   `   r   ibanzProvider.ibanB   s    yy{{t((4/RWWAAAA5AAAAABBv{#F!!!$$ 5(4//r   Fuse_datasetc                 0    |                      d|          S )a6  Generate an 8-digit SWIFT code.

        This method uses |swift| under the hood with the ``length`` argument set
        to ``8`` and with the ``primary`` argument omitted. All 8-digit SWIFT
        codes already refer to the primary branch/office.

        :sample:
        :sample: use_dataset=True
           )lengthrT   swift)r-   rT   s     r   swift8zProvider.swift8M   s     zzz<<<r   primaryc                 2    |                      d||          S )ax  Generate an 11-digit SWIFT code.

        This method uses |swift| under the hood with the ``length`` argument set
        to ``11``. If ``primary`` is set to ``True``, the SWIFT code will always
        end with ``'XXX'``. All 11-digit SWIFT codes use this convention to
        refer to the primary branch/office.

        :sample:
        :sample: use_dataset=True
           )rW   r[   rT   rX   )r-   r[   rT   s      r   swift11zProvider.swift11Y   s     zzW+zNNNr   NrW   c                    ||                      d          }|dvrt          d          |r+t          | d          r|                      | j                  }n!|                     dt
          j                  }|r+t          | d          r|                      | j                  }n.|                     dt
          j        t
          j        z             }|d	k    r|| j	        z   |z   S |rd
}n[|r+t          | d          r|                      | j
                  }n.|                     dt
          j        t
          j        z             }|| j	        z   |z   |z   S )a{  Generate a SWIFT code.

        SWIFT codes, reading from left to right, are composed of a 4 alphabet
        character bank code, a 2 alphabet character country code, a 2
        alphanumeric location code, and an optional 3 alphanumeric branch code.
        This means SWIFT codes can only have 8 or 11 characters, so the value of
        ``length`` can only be ``None`` or the integers ``8`` or ``11``. If the
        value is ``None``, then a value of ``8`` or ``11`` will randomly be
        assigned.

        Because all 8-digit SWIFT codes already refer to the primary branch or
        office, the ``primary`` argument only has an effect if the value of
        ``length`` is ``11``. If ``primary`` is ``True`` and ``length`` is
        ``11``, the 11-digit SWIFT codes generated will always end in ``'XXX'``
        to denote that they belong to primary branches/offices.

        For extra authenticity, localized providers may opt to include SWIFT
        bank codes, location codes, and branch codes used in their respective
        locales. If ``use_dataset`` is ``True``, this method will generate SWIFT
        codes based on those locale-specific codes if included. If those codes
        were not included, then it will behave as if ``use_dataset`` were
        ``False``, and in that mode, all those codes will just be randomly
        generated as per the specification.

        :sample:
        :sample: length=8
        :sample: length=8, use_dataset=True
        :sample: length=11
        :sample: length=11, primary=True
        :sample: length=11, use_dataset=True
        :sample: length=11, primary=True, use_dataset=True
        N)rV   r]   zlength can only be 8 or 11swift_bank_codesz????)lettersswift_location_codesz??rV   XXXswift_branch_codesz???)r<   AssertionErrorr8   r`   lexifystringr   rb   digitsr   rd   )r-   rW   r[   rT   	bank_codelocation_codebranch_codes          r   rY   zProvider.swiftf   sm   L >((11F   !=>>> 	L74);<< 	L!001FGGIIFF4JKKI 	^74)?@@ 	^!%!4!4T5N!O!OMM KKf6Lv}6\K]]MQ;;t00=@@ 	]KK 	]WT+?@@ 	]--d.EFFKK++eV5Kfm5[+\\K4,,}<{JJr   )F)FF)NFF)r;   
__module____qualname____doc__rg   r   r   r   r   __annotations__r   r   r0   r5   r=   rF   rS   boolrZ   r^   r   r"   rY   r!   r   r   r   r      s          RQ&:PQQQE4S>QQQ*K***L##S # # # #!c ! ! ! !/c / / / /#c # # # #
	0c 	0 	0 	0 	0
= 
=$ 
=3 
= 
= 
= 
=O Ot O$ O3 O O O O !%!	?K ?K?K ?K 	?K
 
?K ?K ?K ?K ?K ?Kr   r   )rC   rg   mathr   r   typingr   r   rI   r   	localizeddefault_localer   r!   r   r   <module>ru      s    				        " " " " " " ! ! ! ! ! ! ! !      	WK WK WK WK WK| WK WK WK WK WKr   