Created
April 22, 2015 02:16
-
-
Save zoalasaurusrawr/6980dba0e6c915de91de to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ETL |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project version="4"> | |
| <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | |
| </project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <module type="PYTHON_MODULE" version="4"> | |
| <component name="NewModuleRootManager"> | |
| <content url="file://$MODULE_DIR$" /> | |
| <orderEntry type="inheritedJdk" /> | |
| <orderEntry type="sourceFolder" forTests="false" /> | |
| </component> | |
| </module> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project version="4"> | |
| <component name="DaemonCodeAnalyzer"> | |
| <disable_hints /> | |
| </component> | |
| <component name="DependencyValidationManager"> | |
| <option name="SKIP_IMPORT_STATEMENTS" value="false" /> | |
| </component> | |
| <component name="Encoding" useUTFGuessing="true" native2AsciiForPropertiesFiles="false" /> | |
| <component name="ProjectLevelVcsManager" settingsEditedManually="false"> | |
| <OptionsSetting value="true" id="Add" /> | |
| <OptionsSetting value="true" id="Remove" /> | |
| <OptionsSetting value="true" id="Checkout" /> | |
| <OptionsSetting value="true" id="Update" /> | |
| <OptionsSetting value="true" id="Status" /> | |
| <OptionsSetting value="true" id="Edit" /> | |
| <ConfirmationsSetting value="0" id="Add" /> | |
| <ConfirmationsSetting value="0" id="Remove" /> | |
| </component> | |
| <component name="ProjectModuleManager"> | |
| <modules /> | |
| </component> | |
| <component name="ProjectRootManager" version="2" project-jdk-name="Python 3.4.3 (C:\Python34\python.exe)" project-jdk-type="Python SDK" /> | |
| <component name="PropertiesComponent"> | |
| <property name="last_opened_file_path" value="C:/Python34/python.exe" /> | |
| </component> | |
| <component name="RunManager"> | |
| <list size="0" /> | |
| </component> | |
| </project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project version="4"> | |
| <component name="ProjectModuleManager"> | |
| <modules> | |
| <module fileurl="file://$PROJECT_DIR$/.idea/ETL.iml" filepath="$PROJECT_DIR$/.idea/ETL.iml" /> | |
| </modules> | |
| </component> | |
| </project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <component name="DependencyValidationManager"> | |
| <state> | |
| <option name="SKIP_IMPORT_STATEMENTS" value="false" /> | |
| </state> | |
| </component> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?xml version="1.0" encoding="UTF-8"?> | |
| <project version="4"> | |
| <component name="VcsDirectoryMappings"> | |
| <mapping directory="" vcs="" /> | |
| </component> | |
| </project> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'Will' | |
| from flask import Flask, jsonify, abort, make_response, request | |
| from flask_httpauth import HTTPBasicAuth | |
| import Database | |
| app = Flask(__name__) | |
| auth = HTTPBasicAuth() | |
| @app.route('/') | |
| def index(): | |
| return "Hello, World..." | |
| @auth.get_password | |
| def get_password(username): | |
| if (username== 'will'): | |
| return 'test' | |
| return None | |
| @app.errorhandler(404) | |
| def not_found(error): | |
| return make_response(jsonify({'error' : 'Not found'}), 404) | |
| @auth.error_handler | |
| def unauthorized(): | |
| return make_response(jsonify({'error' : 'Unauthorized'}), 401) | |
| @app.route('/todo/api/v1.0/tasks', methods=['GET']) | |
| @auth.login_required | |
| def get_tasks(): | |
| return jsonify({'tasks': Database.tasks}) | |
| @app.route('/todo/api/v1.0/tasks', methods=['POST']) | |
| def create_task(): | |
| if not request.json or not 'title' in request.json: | |
| abort(400) | |
| task = { | |
| 'id': Database.tasks[-1]['id'] + 1, | |
| 'title': request.json['title'], | |
| 'description': request.json.get('description', ""), | |
| 'done': False | |
| } | |
| Database.tasks.append(task) | |
| return jsonify({'task': task}), 201 | |
| @app.route('/todo/api/v1.0/tasks/<int:task_id>', methods=['PUT']) | |
| def update_task(task_id): | |
| task = [task for task in Database.tasks if task['id'] == task_id] | |
| if len(task) == 0: | |
| abort(404) | |
| if not request.json: | |
| abort(400) | |
| if 'title' not in request.json: | |
| abort(400) | |
| if 'description' not in request.json: | |
| abort(400) | |
| if 'done' in request.json and type(request.json['done']) is not bool: | |
| abort(400) | |
| task[0]['title'] = request.json.get('title', task[0]['title']) | |
| task[0]['description'] = request.json.get('description', task[0]['description']) | |
| task[0]['done'] = request.json.get('done', task[0]['done']) | |
| return jsonify({'task': task[0]}) | |
| @app.route('/todo/api/v1.0/tasks/<int:task_id>', methods=['DELETE']) | |
| def delete_task(task_id): | |
| task = [task for task in Database.tasks if task['id'] == task_id] | |
| if len(task) == 0: | |
| abort(404) | |
| Database.tasks.remove(task[0]) | |
| return jsonify({'result': True}) | |
| @app.route('/todo/api/v1.0/tasks/<int:task_id>', methods=['GET']) | |
| def get_task(task_id): | |
| task = [task for task in Database.tasks if task['id'] == task_id] | |
| if len(task) == 0: | |
| abort(404) | |
| return jsonify({'task': task[0]}) | |
| if __name__ == '__main__': | |
| app.run(debug=True) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'Will' | |
| class mathhelper: | |
| def add(self,num1,num2): | |
| return num1+num2 | |
| def sub(self,num1,num2): | |
| return num1-num2 | |
| def div(self,num1,num2): | |
| return num1/num2 | |
| def mul(self,num1,num2): | |
| return num1*num2 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'Will' | |
| tasks = [ | |
| { | |
| 'id': 1, | |
| 'title': u'Buy groceries', | |
| 'description': u'Milk, Cheese, Pizza, Fruit, Tylenol', | |
| 'done': False | |
| }, | |
| { | |
| 'id': 2, | |
| 'title': u'Learn Python', | |
| 'description': u'Need to find a good Python tutorial on the web', | |
| 'done': False | |
| } | |
| ] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'Will' | |
| class MergeData: | |
| data = {} | |
| def get(self,contextKey): | |
| if contextKey == "": | |
| raise "contextKey must not be blank or null" | |
| self.add("UnitedEpisodeId", self.switchunitedepisode(contextKey)) | |
| return self.data | |
| def add(self,key,value): | |
| self.data[key] = value | |
| return | |
| def switchunitedepisode(self,contextKey): | |
| contextKey = str(contextKey).replace("A0", "CC") | |
| return contextKey |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| __author__ = 'Will' | |
| class RulesEngine: | |
| @staticmethod | |
| def is_equal(self,value,expected_value): | |
| return value == expected_value | |
| @staticmethod | |
| def is_not_equal(self,value,expected_value): | |
| return value != expected_value | |
| @staticmethod | |
| def is_in(self,value,expected_value): | |
| return value in expected_value | |
| @staticmethod | |
| def is_not_in(self,value,expected_value): | |
| return value not in expected_value | |
| @staticmethod | |
| def greater_than(self,value,expected_value): | |
| try: | |
| return int(value) > int(expected_value) | |
| except: | |
| return False | |
| @staticmethod | |
| def less_than(self,value,expected_value): | |
| try: | |
| return int(value) < int(expected_value) | |
| except: | |
| return False |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment