Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
othreecodes authored Dec 16, 2016
1 parent fb18bdc commit f28c8b9
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 0 deletions.
22 changes: 22 additions & 0 deletions LISCENCE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# The MIT License (MIT)

Copyright (c) 2016 Obi Uchenna David <[email protected]>

> Permission is hereby granted, free of charge, to any person obtaining a copy
> of this software and associated documentation files (the "Software"), to deal
> in the Software without restriction, including without limitation the rights
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
> copies of the Software, and to permit persons to whom the Software is
> furnished to do so, subject to the following conditions:
>
> The above copyright notice and this permission notice shall be included in
> all copies or substantial portions of the Software.
>
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
> THE SOFTWARE.
45 changes: 45 additions & 0 deletions pymvrd/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-

__author__ = 'othreecodes'

import requests
from bs4 import BeautifulSoup
BASE_URL = 'http://www.lsmvaapvs.org'
import re
from errors import errors

def parse_response(response):
soup = BeautifulSoup(response.text,"html.parser")
try:
data = soup.find_all('td')
except:
raise errors.InvalidPlateError


'''Cleaning the HTML tags from the string'''
for i in range(0,len(data)):
data[i] = clean_html_tags(str(data[i]))

'''Turning the list into a dict'''
data_dict = dict(zip(*[iter(data)] * 2))
return data_dict


'''Clean the HTML tags from response'''
def clean_html_tags(raw_html):
clean = re.compile('<.*?>')
clean_text = re.sub(clean, '', raw_html)
return clean_text

'''MVRD class'''
class Mvrd:
def __init__(self,plate_number):
self.plate_number = plate_number

'''Getting the raw html from www.lsmvaapvs.org'''
def get_data(self):
response = requests.get(BASE_URL+'/search.php',{'vpn':self.plate_number})
data = parse_response(response=response)
return data

11 changes: 11 additions & 0 deletions pymvrd/errors/errors.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
class Mvrd(Exception):
'''
MVRD Exception
'''
pass

class InvalidPlateError(Exception):
'''
The Plate number Entered was Invalid
'''

2 changes: 2 additions & 0 deletions setup.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[metadata]
description-file = README.md
13 changes: 13 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
from distutils.core import setup
setup(
name = 'pymvrd',
packages = ['pymvrd'],
version = '0.1',
description = 'Motor Vehicle Registration Information Search Portal Library',
author = 'Obi Uchenna David',
author_email = '[email protected]',
url = 'https://github.com/othreecodes/pymvrd',
download_url = 'https://github.com/othreecodes/pymvrd/tarball/0.1',
keywords = ['vehicle','plate number','registration'],
classifiers = [],
)

0 comments on commit f28c8b9

Please sign in to comment.