GitHub PullRequestReviewCommentEvent at 2014-10-12 23:59:31
Repository: gaenv
Actor: leourbina
Payload: {"action":"created","comment":{"url":"https://api.github.com/repos/faisalraja/gaenv/pulls/comments/18751285","id":18751285,"diff_hunk":"@@ -1,59 +1,71 @@\n-#\n+#!/usr/bin/env python\n+'''\n+Utility to create python package symlinks for deployment in GAE. Before running this script, you must run pip install <requirements>.\n+\n+Usage: gaenv [options]\n+\n+Options:\n+    -r --requirements=FILE\t\tSpecify the requirements  [default: requirements.txt]\n+    -l --lib=DIR                        Change the the output dir [default: gaenv_lib]\n+    -n --no-import\t\t\tWill not add import statement to appengine_config.py\n+'''\n from distutils.sysconfig import get_python_lib\n+from docopt import docopt\n import os\n import inspect\n-import argparse\n import re\n import pkg_resources\n import sys\n import ctypes\n \n-sys_path_build = \"\"\"# Auto generated by gaenv\n+SYS_PATH_BUILD = \"\"\"# Auto generated by gaenv\n import sys\n import os\n sys.path.insert(0, os.path.dirname(__file__))\"\"\"\n \n-\n-def create_symlink(source, link_name):\n-    os_symlink = getattr(os, \"symlink\", None)\n-    if callable(os_symlink):\n-        os_symlink(source, link_name)\n-    else:\n-        csl = ctypes.windll.kernel32.CreateSymbolicLinkW\n-        csl.argtypes = (ctypes.c_wchar_p, ctypes.c_wchar_p, ctypes.c_uint32)\n-        csl.restype = ctypes.c_ubyte\n-        flags = 1 if os.path.isdir(source) else 0\n-        if csl(link_name, source, flags) == 0:\n-            raise ctypes.WinError()\n-\n-\n def main():\n-    parser = argparse.ArgumentParser(description='Command line utility for managing appengine thirdparty packages')\n-    parser.add_argument('--requirements', type=str, default='requirements.txt',\n-                        help='specify the requirements file default(requirements.txt)')\n-    parser.add_argument('--lib', type=str, default='gaenv_lib',\n-                        help='change the output dir, default is gaenv_lib')\n-    parser.add_argument('--no-import', action='store_true',\n-                        help='will not add import statement on appengine_config.py')\n-    args = parser.parse_args()\n-\n-    # Build requirements path & check for existence\n+    args = docopt(__doc__, version='gaenv 0.1.8')\n     current_path = os.getcwd()\n-    requirement_path = os.path.join(current_path, args.requirements)\n+    requirement_path = get_requirements_path(current_path, args['--requirements'])\n+    pypi_requirements, cvs_requirements = compute_requirements(requirement_path)\n+    requirements = parse_requirements(pypi_requirements, cvs_requirements)\n+\n+    links = compute_package_links(requirements)\n+    if links:\n+        libs_directory = create_libs_directory(current_path, args['--lib'])\n+        create_package_links(libs_directory, links)\n+        if not args['--no-import']:\n+            appengine_config_path = os.path.join(current_path, 'appengine_config.py')\n+            config_source = get_appengine_config(appengine_config_path)\n+            add_import(appengine_config_path, config_source, args['--lib'])\n+\n+def get_requirements_path(current_path, requirements_file):\n+    requirement_path = os.path.join(current_path, requirements_file)\n     if not os.path.exists(requirement_path):\n         print 'requirements file %s not found' % requirement_path\n-        exit(0)\n+        sys.exit(1)\n+    return requirement_path\n \n-    with open(requirement_path, 'r') as file:\n-        requirements = file.readlines()\n-        pypi_requirements = []\n-        cvs_requirements = []\n+def compute_requirements(requirement_path):\n+    pypi_requirements = []\n+    cvs_requirements = []\n+    with open(requirement_path, 'r') as requirements:\n         for requirement in requirements:\n-            if requirement.find('+') == -1:\n+            if requirement.startswith('-r') or requirement.startswith('--requirement'):\n+                extra_pypi_requirements, extra_cvs_requirements = compute_requirements(requirement.split(\" \")[1].strip())\n+                pypi_requirements += extra_pypi_requirements\n+                cvs_requirements += extra_cvs_requirements\n+            elif requirement.startswith('--'):","path":"gaenv/__init__.py","position":92,"original_position":92,"commit_id":"c228fcf447b318947d1921c42731deaa3f7801d9","original_commit_id":"c228fcf447b318947d1921c42731deaa3f7801d9","user":{"login":"leourbina","id":434020,"avatar_url":"https://avatars.githubusercontent.com/u/434020?v=2","gravatar_id":"","url":"https://api.github.com/users/leourbina","html_url":"https://github.com/leourbina","followers_url":"https://api.github.com/users/leourbina/followers","following_url":"https://api.github.com/users/leourbina/following{/other_user}","gists_url":"https://api.github.com/users/leourbina/gists{/gist_id}","starred_url":"https://api.github.com/users/leourbina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leourbina/subscriptions","organizations_url":"https://api.github.com/users/leourbina/orgs","repos_url":"https://api.github.com/users/leourbina/repos","events_url":"https://api.github.com/users/leourbina/events{/privacy}","received_events_url":"https://api.github.com/users/leourbina/received_events","type":"User","site_admin":false},"body":"Ignore flags embedded in requirements.txt files.","created_at":"2014-10-12T23:59:31Z","updated_at":"2014-10-12T23:59:31Z","html_url":"https://github.com/faisalraja/gaenv/pull/6#discussion_r18751285","pull_request_url":"https://api.github.com/repos/faisalraja/gaenv/pulls/6","_links":{"self":{"href":"https://api.github.com/repos/faisalraja/gaenv/pulls/comments/18751285"},"html":{"href":"https://github.com/faisalraja/gaenv/pull/6#discussion_r18751285"},"pull_request":{"href":"https://api.github.com/repos/faisalraja/gaenv/pulls/6"}}},"pull_request":{"url":"https://api.github.com/repos/faisalraja/gaenv/pulls/6","id":22620842,"html_url":"https://github.com/faisalraja/gaenv/pull/6","diff_url":"https://github.com/faisalraja/gaenv/pull/6.diff","patch_url":"https://github.com/faisalraja/gaenv/pull/6.patch","issue_url":"https://api.github.com/repos/faisalraja/gaenv/issues/6","number":6,"state":"open","locked":false,"title":"Major refactoring and bug fixes","user":{"login":"leourbina","id":434020,"avatar_url":"https://avatars.githubusercontent.com/u/434020?v=2","gravatar_id":"","url":"https://api.github.com/users/leourbina","html_url":"https://github.com/leourbina","followers_url":"https://api.github.com/users/leourbina/followers","following_url":"https://api.github.com/users/leourbina/following{/other_user}","gists_url":"https://api.github.com/users/leourbina/gists{/gist_id}","starred_url":"https://api.github.com/users/leourbina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leourbina/subscriptions","organizations_url":"https://api.github.com/users/leourbina/orgs","repos_url":"https://api.github.com/users/leourbina/repos","events_url":"https://api.github.com/users/leourbina/events{/privacy}","received_events_url":"https://api.github.com/users/leourbina/received_events","type":"User","site_admin":false},"body":"* Allows for recursive requirements files (via the -r flag)\r\n* Ignores options set inside the requirements file (besides -r)\r\n* Refactors the code into smaller chunks to make it easier to read/test.\r\n* Uses docopt for easier command line parsing.","created_at":"2014-10-12T21:57:10Z","updated_at":"2014-10-12T23:59:31Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4b1b976ae25b5f8388a1a58139b2250446214549","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/faisalraja/gaenv/pulls/6/commits","review_comments_url":"https://api.github.com/repos/faisalraja/gaenv/pulls/6/comments","review_comment_url":"https://api.github.com/repos/faisalraja/gaenv/pulls/comments/{number}","comments_url":"https://api.github.com/repos/faisalraja/gaenv/issues/6/comments","statuses_url":"https://api.github.com/repos/faisalraja/gaenv/statuses/c228fcf447b318947d1921c42731deaa3f7801d9","head":{"label":"leourbina:master","ref":"master","sha":"c228fcf447b318947d1921c42731deaa3f7801d9","user":{"login":"leourbina","id":434020,"avatar_url":"https://avatars.githubusercontent.com/u/434020?v=2","gravatar_id":"","url":"https://api.github.com/users/leourbina","html_url":"https://github.com/leourbina","followers_url":"https://api.github.com/users/leourbina/followers","following_url":"https://api.github.com/users/leourbina/following{/other_user}","gists_url":"https://api.github.com/users/leourbina/gists{/gist_id}","starred_url":"https://api.github.com/users/leourbina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leourbina/subscriptions","organizations_url":"https://api.github.com/users/leourbina/orgs","repos_url":"https://api.github.com/users/leourbina/repos","events_url":"https://api.github.com/users/leourbina/events{/privacy}","received_events_url":"https://api.github.com/users/leourbina/received_events","type":"User","site_admin":false},"repo":{"id":25129234,"name":"gaenv","full_name":"leourbina/gaenv","owner":{"login":"leourbina","id":434020,"avatar_url":"https://avatars.githubusercontent.com/u/434020?v=2","gravatar_id":"","url":"https://api.github.com/users/leourbina","html_url":"https://github.com/leourbina","followers_url":"https://api.github.com/users/leourbina/followers","following_url":"https://api.github.com/users/leourbina/following{/other_user}","gists_url":"https://api.github.com/users/leourbina/gists{/gist_id}","starred_url":"https://api.github.com/users/leourbina/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leourbina/subscriptions","organizations_url":"https://api.github.com/users/leourbina/orgs","repos_url":"https://api.github.com/users/leourbina/repos","events_url":"https://api.github.com/users/leourbina/events{/privacy}","received_events_url":"https://api.github.com/users/leourbina/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/leourbina/gaenv","description":"Tool to manage packages for google app engine python","fork":true,"url":"https://api.github.com/repos/leourbina/gaenv","forks_url":"https://api.github.com/repos/leourbina/gaenv/forks","keys_url":"https://api.github.com/repos/leourbina/gaenv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/leourbina/gaenv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/leourbina/gaenv/teams","hooks_url":"https://api.github.com/repos/leourbina/gaenv/hooks","issue_events_url":"https://api.github.com/repos/leourbina/gaenv/issues/events{/number}","events_url":"https://api.github.com/repos/leourbina/gaenv/events","assignees_url":"https://api.github.com/repos/leourbina/gaenv/assignees{/user}","branches_url":"https://api.github.com/repos/leourbina/gaenv/branches{/branch}","tags_url":"https://api.github.com/repos/leourbina/gaenv/tags","blobs_url":"https://api.github.com/repos/leourbina/gaenv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/leourbina/gaenv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/leourbina/gaenv/git/refs{/sha}","trees_url":"https://api.github.com/repos/leourbina/gaenv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/leourbina/gaenv/statuses/{sha}","languages_url":"https://api.github.com/repos/leourbina/gaenv/languages","stargazers_url":"https://api.github.com/repos/leourbina/gaenv/stargazers","contributors_url":"https://api.github.com/repos/leourbina/gaenv/contributors","subscribers_url":"https://api.github.com/repos/leourbina/gaenv/subscribers","subscription_url":"https://api.github.com/repos/leourbina/gaenv/subscription","commits_url":"https://api.github.com/repos/leourbina/gaenv/commits{/sha}","git_commits_url":"https://api.github.com/repos/leourbina/gaenv/git/commits{/sha}","comments_url":"https://api.github.com/repos/leourbina/gaenv/comments{/number}","issue_comment_url":"https://api.github.com/repos/leourbina/gaenv/issues/comments/{number}","contents_url":"https://api.github.com/repos/leourbina/gaenv/contents/{+path}","compare_url":"https://api.github.com/repos/leourbina/gaenv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/leourbina/gaenv/merges","archive_url":"https://api.github.com/repos/leourbina/gaenv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/leourbina/gaenv/downloads","issues_url":"https://api.github.com/repos/leourbina/gaenv/issues{/number}","pulls_url":"https://api.github.com/repos/leourbina/gaenv/pulls{/number}","milestones_url":"https://api.github.com/repos/leourbina/gaenv/milestones{/number}","notifications_url":"https://api.github.com/repos/leourbina/gaenv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/leourbina/gaenv/labels{/name}","releases_url":"https://api.github.com/repos/leourbina/gaenv/releases{/id}","created_at":"2014-10-12T19:15:45Z","updated_at":"2014-10-12T20:47:35Z","pushed_at":"2014-10-12T21:59:24Z","git_url":"git://github.com/leourbina/gaenv.git","ssh_url":"git@github.com:leourbina/gaenv.git","clone_url":"https://github.com/leourbina/gaenv.git","svn_url":"https://github.com/leourbina/gaenv","homepage":"","size":95,"stargazers_count":0,"watchers_count":0,"language":"Python","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"faisalraja:master","ref":"master","sha":"3d1f4a5b33c5cbbe74f15037120c0763f687354c","user":{"login":"faisalraja","id":3916729,"avatar_url":"https://avatars.githubusercontent.com/u/3916729?v=2","gravatar_id":"","url":"https://api.github.com/users/faisalraja","html_url":"https://github.com/faisalraja","followers_url":"https://api.github.com/users/faisalraja/followers","following_url":"https://api.github.com/users/faisalraja/following{/other_user}","gists_url":"https://api.github.com/users/faisalraja/gists{/gist_id}","starred_url":"https://api.github.com/users/faisalraja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faisalraja/subscriptions","organizations_url":"https://api.github.com/users/faisalraja/orgs","repos_url":"https://api.github.com/users/faisalraja/repos","events_url":"https://api.github.com/users/faisalraja/events{/privacy}","received_events_url":"https://api.github.com/users/faisalraja/received_events","type":"User","site_admin":false},"repo":{"id":10700265,"name":"gaenv","full_name":"faisalraja/gaenv","owner":{"login":"faisalraja","id":3916729,"avatar_url":"https://avatars.githubusercontent.com/u/3916729?v=2","gravatar_id":"","url":"https://api.github.com/users/faisalraja","html_url":"https://github.com/faisalraja","followers_url":"https://api.github.com/users/faisalraja/followers","following_url":"https://api.github.com/users/faisalraja/following{/other_user}","gists_url":"https://api.github.com/users/faisalraja/gists{/gist_id}","starred_url":"https://api.github.com/users/faisalraja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/faisalraja/subscriptions","organizations_url":"https://api.github.com/users/faisalraja/orgs","repos_url":"https://api.github.com/users/faisalraja/repos","events_url":"https://api.github.com/users/faisalraja/events{/privacy}","received_events_url":"https://api.github.com/users/faisalraja/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/faisalraja/gaenv","description":"Tool to manage packages for google app engine python","fork":false,"url":"https://api.github.com/repos/faisalraja/gaenv","forks_url":"https://api.github.com/repos/faisalraja/gaenv/forks","keys_url":"https://api.github.com/repos/faisalraja/gaenv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/faisalraja/gaenv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/faisalraja/gaenv/teams","hooks_url":"https://api.github.com/repos/faisalraja/gaenv/hooks","issue_events_url":"https://api.github.com/repos/faisalraja/gaenv/issues/events{/number}","events_url":"https://api.github.com/repos/faisalraja/gaenv/events","assignees_url":"https://api.github.com/repos/faisalraja/gaenv/assignees{/user}","branches_url":"https://api.github.com/repos/faisalraja/gaenv/branches{/branch}","tags_url":"https://api.github.com/repos/faisalraja/gaenv/tags","blobs_url":"https://api.github.com/repos/faisalraja/gaenv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/faisalraja/gaenv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/faisalraja/gaenv/git/refs{/sha}","trees_url":"https://api.github.com/repos/faisalraja/gaenv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/faisalraja/gaenv/statuses/{sha}","languages_url":"https://api.github.com/repos/faisalraja/gaenv/languages","stargazers_url":"https://api.github.com/repos/faisalraja/gaenv/stargazers","contributors_url":"https://api.github.com/repos/faisalraja/gaenv/contributors","subscribers_url":"https://api.github.com/repos/faisalraja/gaenv/subscribers","subscription_url":"https://api.github.com/repos/faisalraja/gaenv/subscription","commits_url":"https://api.github.com/repos/faisalraja/gaenv/commits{/sha}","git_commits_url":"https://api.github.com/repos/faisalraja/gaenv/git/commits{/sha}","comments_url":"https://api.github.com/repos/faisalraja/gaenv/comments{/number}","issue_comment_url":"https://api.github.com/repos/faisalraja/gaenv/issues/comments/{number}","contents_url":"https://api.github.com/repos/faisalraja/gaenv/contents/{+path}","compare_url":"https://api.github.com/repos/faisalraja/gaenv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/faisalraja/gaenv/merges","archive_url":"https://api.github.com/repos/faisalraja/gaenv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/faisalraja/gaenv/downloads","issues_url":"https://api.github.com/repos/faisalraja/gaenv/issues{/number}","pulls_url":"https://api.github.com/repos/faisalraja/gaenv/pulls{/number}","milestones_url":"https://api.github.com/repos/faisalraja/gaenv/milestones{/number}","notifications_url":"https://api.github.com/repos/faisalraja/gaenv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/faisalraja/gaenv/labels{/name}","releases_url":"https://api.github.com/repos/faisalraja/gaenv/releases{/id}","created_at":"2013-06-15T00:30:38Z","updated_at":"2014-10-12T19:03:47Z","pushed_at":"2014-02-14T20:23:16Z","git_url":"git://github.com/faisalraja/gaenv.git","ssh_url":"git@github.com:faisalraja/gaenv.git","clone_url":"https://github.com/faisalraja/gaenv.git","svn_url":"https://github.com/faisalraja/gaenv","homepage":"","size":167,"stargazers_count":21,"watchers_count":21,"language":"Python","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":2,"forks":4,"open_issues":2,"watchers":21,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/faisalraja/gaenv/pulls/6"},"html":{"href":"https://github.com/faisalraja/gaenv/pull/6"},"issue":{"href":"https://api.github.com/repos/faisalraja/gaenv/issues/6"},"comments":{"href":"https://api.github.com/repos/faisalraja/gaenv/issues/6/comments"},"review_comments":{"href":"https://api.github.com/repos/faisalraja/gaenv/pulls/6/comments"},"review_comment":{"href":"https://api.github.com/repos/faisalraja/gaenv/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/faisalraja/gaenv/pulls/6/commits"},"statuses":{"href":"https://api.github.com/repos/faisalraja/gaenv/statuses/c228fcf447b318947d1921c42731deaa3f7801d9"}}}}