Giter Club home page Giter Club logo

vininfo's People

Contributors

casual-citroen-enjoyer avatar dsandshr avatar ghilesmeddour avatar idlesign avatar jliles avatar ribeiro-breno avatar slipovenko avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vininfo's Issues

AttributeError

Hi, i'm getting this error on some vin's

In [1]: import vininfo

In [2]: vininfo.Vin("2LNBL8EV9AX604020")
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-2-267facbdc2ff> in <module>
----> 1 vininfo.Vin("2LNBL8EV9AX604020")

/usr/lib/python3.6/site-packages/vininfo/toolbox.py in __init__(self, num)
     28         self.num = self.validate(num)
     29 
---> 30         details_extractor = self.brand.extractor
     31 
     32         if details_extractor:

AttributeError: 'NoneType' object has no attribute 'extractor'

... Some more failing ...
2LMHJ5NK8EBL51686
5J8YD4H5XKL000637
19XFC2F74GE219952
2LNBL8CV9AX610404
58ABK1GG9HU067426
3CZRM3H59CG705077
2LNHM82V09X602289
2LMHJ5NKXEBL54766
2HNYD2H34CH544142
2C4RDGCG3HR589219
2HNYD2H69BH528012
2HNYD28218H504518
2HNYD28378H536818
19XFC1F76GE220868
2LNBL8CV1BX754840
2C4RDGCG6DR590925
2C4RDGCG3HR857170
2C4RDGBG1CR392642
2A4RR5D13AR299997
2LMHJ5NK4EBL51281
2HNYD2H36CH513331
2LMHJ5AR1ABJ50404
2LNBL8EV4BX754439
2LMDJ8JK9FBL32362

Vin().validate() requires vin that is already given

It seems irrational to be, but to make validate (classmethod) work, you have to instantiate the Vin with a VIN number and call validate again with a VIN number.

Vin('someVIN').validate('someVIN') is the only way that I managed to make it work.
In my humble opinion, you should be able to check like so:

vin = 'SomeVIN'
vin_object = Vin(vin)
vin_object.validate() # This returns True or False

P.S.1:
Or even better would be:

vin = 'SomeVIN'
vin_object = Vin(vin)
if vin_object.is_valid:  # This returns True or False
    print('Yay!')
vin_object.is_valid_with_exception()  # or something like that
>>> InvalidVIN: This VIN number is invalid.

P.S.2:
I had an idea:

def validate(self, num: str = None, with_exception: bool = False) -> str:
        """Performs basic VIN validation and sanation.

        :param num: Other VIN to check
        :param with_exception: Flag to determine if the validate function should raise an exception or not.


        """
        if num is None:
                num = self.num
        num = num.strip().upper()

        if len(num) != 17:
                raise ValidationError(f'VIN number requires 17 chars ({num_len} given)')

        pattern = r"^[A-HJ-NPR-Z0-9]{17}$"
        if not re.match(pattern, num):
                if with_exception:
                        raise ValidationError(f"VIN number must only contain alphanumeric symbols except 'I', 'O', and 'Q' ")
                else:
                        return False
                return True

Cheers ๐Ÿบ

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.