PK!_H88 LICENSE.txtThe MIT License (MIT) Copyright (c) 2019 Almer Mendoza 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. PK!--froi/__init__.pyfrom .froi import Froi __version__ = '0.1.0' PK!A^froi/exceptions.pyclass AppNotDefined(Exception): """All routes will fail if app is not defined""" def __init__(self, message): self.message = message def __str__(self): return self.message class HttpMethodConflict(Exception): """Defined HTTP methods with defined function once""" def __init__(self, message): self.message = message def __str__(self): return self.message PK!VcXX froi/froi.pyimport json from flask import request from .route import Route from .exceptions import AppNotDefined, HttpMethodConflict class Froi(Route): """ Template for all routes to be created for APIs. A Flask wrapper that installs routes as defined from a class. It will accept :app: as paremeter that will be the server's context and will be used to set route. """ def __init__(self, app, component_name, prefix=''): self.component_name = component_name self.prefix = prefix if app.add_url_rule is None: raise AppNotDefined('Sent `app` is not valid') self.app = app self.method = [] def route(self, url='', **kwargs): """Wrap server method's route""" add = self.app.add_url_rule add('{}{}'.format(self.prefix, url), methods=self.getmethods(), **kwargs) # handle forward slash if self.prefix is not '' or url is not '': add('{}{}/'.format(self.prefix, url), methods=self.getmethods(), **kwargs) self.method = [] def install(self): """Attach routes to defined app""" self.setall().route(view_func=self.sethttp) def _check_methods(self, method): if method in self.method: raise HttpMethodConflict('Multiple {} in methods'.format(method)) if self.method is not None: self.method += [method] return self.method = [method] def setall(self): self.method = ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEADER'] return self def setget(self): self._check_methods('GET') return self def setpost(self): self._check_methods('POST') return self def setput(self): self._check_methods('PUT') return self def setdelete(self): self._check_methods('DELETE') return self def setoptions(self): self._check_methods('OPTIONS') return self def setheader(self): self._check_methods('HEADER') return self PK!PJww froi/route.pyfrom flask import request class MethodSwitch: def __init__(self): self.get = False self.post = False self.put = False self.delete = False self.options = False self.header = False class Route: """ Consolidate all route logic into one logic. The goal is to be able to define an object :Route: that will handle endpoints on multiple methods. """ isblank = MethodSwitch() def __init__(self): pass def _setmethod(self, methods, method): if not getattr(self.isblank, method.lower()): methods += [method] def getmethods(self): methods = [] for m in ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'HEADER']: self._setmethod(methods, m) return methods def get(self): self.isblank.get = True pass def post(self): self.isblank.post = True pass def put(self): self.isblank.put = True pass def delete(self): self.isblank.delete = True pass def options(self): self.isblank.options = True pass def header(self): self.isblank.header = True pass def sethttp(self): method = request.method if method and not getattr(self.isblank, method): outbound_fxn = getattr(self, method) outbound_fxn() PK!_H88 froi-0.2.1.dist-info/LICENSE.txtThe MIT License (MIT) Copyright (c) 2019 Almer Mendoza 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. PK!HڽTUfroi-0.2.1.dist-info/WHEEL A н#Z;/"d&F[xzw@Zpy3Fv]\fi4WZ^EgM_-]#0(q7PK!H<froi-0.2.1.dist-info/METADATAU[o0~8mֻ!Etb&Z <^r;κ9v6o!wc_pbZEp̏DAfdC%(D0?`mDYVB9ѕC )fRa tVZN!8>XR/ϓov)T6.3nڤHEL$}5lTQ\C)i^J/2@Bxɻ. A;3lxOo_C2H|!zv4jBE!.ZVo0lfW⹴{6<&FH0x \MIqx:>W[Snuh0\_,F[Ne,ؖ5ݾ"tFe.rvSn-nq| xZ !oe9cCS:A)ƀ+]kn7.F(qķfdrzA/ "( c<վnoIXW- ں Ȗ[tEuU*ZA 8W^GJmݓN`sVh*0S=)!bä{Z_Qx9#mteȭiUǷ0m-NcCeKP"6&ZerGi<]{AaXGrZsS)cOB9fj lrmFFVI! C]PaLt뜘mIҺL%x+I3'-%M=