diff --git a/swh/web/api/views/origin.py b/swh/web/api/views/origin.py --- a/swh/web/api/views/origin.py +++ b/swh/web/api/views/origin.py @@ -60,19 +60,22 @@ (default to 100, can not exceed 10000) :>jsonarr number id: the origin unique identifier - :>jsonarr string origin_visits_url: link to in order to get information about the - visits for that origin - :>jsonarr string type: the type of software origin (possible values are ``git``, ``svn``, - ``hg``, ``deb``, ``pypi``, ``npm``, ``ftp`` or ``deposit``) + :>jsonarr string origin_visits_url: link to in order to get information + about the visits for that origin + :>jsonarr string type: the type of software origin (possible values + are ``git``, ``svn``, ``hg``, ``deb``, ``pypi``, ``npm``, ``ftp`` + or ``deposit``) :>jsonarr string url: the origin canonical url :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request - :resheader Link: indicates that a subsequent or previous result page are available - and contains the urls pointing to them + :resheader Content-Type: this depends on :http:header:`Accept` header + of request + :resheader Link: indicates that a subsequent or previous result page + are available and contains the urls pointing to them - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error @@ -81,7 +84,7 @@ .. parsed-literal:: :swh_web_api:`origins?origin_from=50000&origin_count=500` - """ # noqa + """ origin_from = int(request.query_params.get('origin_from', '1')) origin_count = int(request.query_params.get('origin_count', '100')) origin_count = min(origin_count, 10000) @@ -111,17 +114,20 @@ :param int origin_id: a software origin identifier :>json number id: the origin unique identifier - :>json string origin_visits_url: link to in order to get information about the - visits for that origin - :>json string type: the type of software origin (possible values are ``git``, ``svn``, - ``hg``, ``deb``, ``pypi``, ``npm``, ``ftp`` or ``deposit``) + :>json string origin_visits_url: link to in order to get information + about the visits for that origin + :>json string type: the type of software origin (possible values are + ``git``, ``svn``, ``hg``, ``deb``, ``pypi``, ``npm``, ``ftp`` or + ``deposit``) :>json string url: the origin canonical url :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on :http:header:`Accept` header + of request - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 404: requested origin can not be found in the archive @@ -136,21 +142,24 @@ Get information about a software origin. - :param string origin_type: the origin type (possible values are ``git``, ``svn``, - ``hg``, ``deb``, ``pypi``, ``npm``, ``ftp`` or ``deposit``) + :param string origin_type: the origin type (possible values are + ``git``, ``svn``, ``hg``, ``deb``, ``pypi``, ``npm``, ``ftp`` or + ``deposit``) :param string origin_url: the origin url :>json number id: the origin unique identifier - :>json string origin_visits_url: link to in order to get information about the - visits for that origin + :>json string origin_visits_url: link to in order to get information + about the visits for that origin :>json string type: the type of software origin :>json string url: the origin canonical url - :reqheader Accept: the requested response content type, - either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :reqheader Accept: the requested response content type, either + ``application/json`` (default) or ``application/yaml`` + :resheader Content-Type: this depends on :http:header:`Accept` header + of request - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 404: requested origin can not be found in the archive @@ -160,7 +169,7 @@ .. parsed-literal:: :swh_web_api:`origin/git/url/https://github.com/python/cpython/` - """ # noqa + """ ori_dict = { 'id': int(origin_id) if origin_id else None, 'type': origin_type, @@ -191,24 +200,27 @@ The search is performed in a case insensitive way. :param string url_pattern: a string pattern or a regular expression - :query int offset: the number of found origins to skip before returning results + :query int offset: the number of found origins to skip before returning + results :query int limit: the maximum number of found origins to return - :query boolean regexp: if true, consider provided pattern as a regular expression - and search origins whose urls match it - :query boolean with_visit: if true, only return origins with at least one visit - by Software heritage + :query boolean regexp: if true, consider provided pattern as a regular + expression and search origins whose urls match it + :query boolean with_visit: if true, only return origins with at least + one visit by Software heritage :>jsonarr number id: the origin unique identifier - :>jsonarr string origin_visits_url: link to in order to get information about the - visits for that origin + :>jsonarr string origin_visits_url: link to in order to get information + about the visits for that origin :>jsonarr string type: the type of software origin :>jsonarr string url: the origin canonical url :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on :http:header:`Accept` header + of request - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error @@ -217,7 +229,7 @@ .. parsed-literal:: :swh_web_api:`origin/search/python/?limit=2` - """ # noqa + """ result = {} offset = int(request.query_params.get('offset', '0')) limit = int(request.query_params.get('limit', '70')) @@ -259,22 +271,26 @@ JSON-LD/CodeMeta dictionary) match the provided criteria. For now, only full-text search on this dictionary is supported. - :query str fulltext: a string that will be matched against origin metadata; - results are ranked and ordered starting with the best ones. + :query str fulltext: a string that will be matched against origin + metadata; results are ranked and ordered starting with the best + ones. :query int limit: the maximum number of found origins to return (bounded to 100) :>jsonarr number origin_id: the origin unique identifier - :>jsonarr dict metadata: metadata of the origin (as a JSON-LD/CodeMeta dictionary) + :>jsonarr dict metadata: metadata of the origin (as a + JSON-LD/CodeMeta dictionary) :>jsonarr string from_revision: the revision used to extract these metadata (the current HEAD or one of the former HEADs) :>jsonarr dict tool: the tool used to extract these metadata :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on :http:header:`Accept` header + of request - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error @@ -283,7 +299,7 @@ .. parsed-literal:: :swh_web_api:`origin/metadata-search/?limit=2&fulltext=Jane%20Doe` - """ # noqa + """ fulltext = request.query_params.get('fulltext', None) limit = min(int(request.query_params.get('limit', '70')), 100) @@ -309,26 +325,33 @@ to their date. :param int origin_id: a software origin identifier - :query int per_page: specify the number of visits to list, for pagination purposes - :query int last_visit: visit to start listing from, for pagination purposes + :query int per_page: specify the number of visits to list, for + pagination purposes + :query int last_visit: visit to start listing from, for pagination + purposes :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request - :resheader Link: indicates that a subsequent result page is available and contains - the url pointing to it + :resheader Content-Type: this depends on :http:header:`Accept` header + of request + :resheader Link: indicates that a subsequent result page is available + and contains the url pointing to it :>jsonarr string date: ISO representation of the visit date (in UTC) :>jsonarr number id: the unique identifier of the origin - :>jsonarr string origin_visit_url: link to :http:get:`/api/1/origin/(origin_id)/visit/(visit_id)/` - in order to get information about the visit + :>jsonarr string origin_visit_url: link to + :http:get:`/api/1/origin/(origin_id)/visit/(visit_id)/` in order to + get information about the visit :>jsonarr string snapshot: the snapshot identifier of the visit - :>jsonarr string snapshot_url: link to :http:get:`/api/1/snapshot/(snapshot_id)/` - in order to get information about the snapshot of the visit - :>jsonarr string status: status of the visit (either **full**, **partial** or **ongoing**) + :>jsonarr string snapshot_url: link to + :http:get:`/api/1/snapshot/(snapshot_id)/` in order to get + information about the snapshot of the visit + :>jsonarr string status: status of the visit (either **full**, + **partial** or **ongoing**) :>jsonarr number visit: the unique identifier of the visit - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 404: requested origin can not be found in the archive @@ -338,7 +361,7 @@ .. parsed-literal:: :swh_web_api:`origin/1/visits/` - """ # noqa + """ result = {} origin_id = int(origin_id) per_page = int(request.query_params.get('per_page', '10')) @@ -402,30 +425,35 @@ :param int origin_id: a software origin identifier :param int visit_id: a visit identifier - :reqheader Accept: the requested response content type, - either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :reqheader Accept: the requested response content type, either + ``application/json`` (default) or ``application/yaml`` + :resheader Content-Type: this depends on :http:header:`Accept` + header of request :>json string date: ISO representation of the visit date (in UTC) :>json number origin: the origin unique identifier :>json string origin_url: link to get information about the origin :>jsonarr string snapshot: the snapshot identifier of the visit - :>jsonarr string snapshot_url: link to :http:get:`/api/1/snapshot/(snapshot_id)/` - in order to get information about the snapshot of the visit - :>json string status: status of the visit (either **full**, **partial** or **ongoing**) + :>jsonarr string snapshot_url: link to + :http:get:`/api/1/snapshot/(snapshot_id)/` in order to get + information about the snapshot of the visit + :>json string status: status of the visit (either **full**, + **partial** or **ongoing**) :>json number visit: the unique identifier of the visit - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error - :statuscode 404: requested origin or visit can not be found in the archive + :statuscode 404: requested origin or visit can not be found in the + archive **Example:** .. parsed-literal:: :swh_web_api:`origin/1500/visit/1/` - """ # noqa + """ return api_lookup( service.lookup_origin_visit, int(origin_id), int(visit_id), notfound_msg=('No visit {} for origin {} found' diff --git a/swh/web/api/views/origin_save.py b/swh/web/api/views/origin_save.py --- a/swh/web/api/views/origin_save.py +++ b/swh/web/api/views/origin_save.py @@ -36,19 +36,20 @@ * **put in pending state** until a manual check is done in order to determine if it can be loaded or not - Once a saving request has been accepted, its associated saving task status can - then be checked through a GET request on the same url. Returned status can either be: + Once a saving request has been accepted, its associated saving task + status can then be checked through a GET request on the same url. + Returned status can either be: * **not created**: no saving task has been created - * **not yet scheduled**: saving task has been created but its execution has not - yet been scheduled + * **not yet scheduled**: saving task has been created but its + execution has not yet been scheduled * **scheduled**: the task execution has been scheduled * **succeed**: the saving task has been successfully executed * **failed**: the saving task has been executed but it failed - When issuing a POST request an object will be returned while a GET request will - return an array of objects (as multiple save requests might have been submitted - for the same origin). + When issuing a POST request an object will be returned while a GET + request will return an array of objects (as multiple save requests + might have been submitted for the same origin). :param string origin_type: the type of origin to save (currently the supported types are ``git``, ``hg`` and ``svn``) @@ -56,23 +57,27 @@ :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on :http:header:`Accept` + header of request :>json string origin_url: the url of the origin to save :>json string origin_type: the type of the origin to save - :>json string save_request_date: the date (in iso format) the save request was issued - :>json string save_request_status: the status of the save request, either **accepted**, - **rejected** or **pending** - :>json string save_task_status: the status of the origin saving task, either **not created**, - **not yet scheduled**, **scheduled**, **succeed** or **failed** + :>json string save_request_date: the date (in iso format) the save + request was issued + :>json string save_request_status: the status of the save request, + either **accepted**, **rejected** or **pending** + :>json string save_task_status: the status of the origin saving task, + either **not created**, **not yet scheduled**, **scheduled**, + **succeed** or **failed** - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, + :http:method:`head`, :http:method:`options` :statuscode 200: no error :statuscode 400: an invalid origin type or url has been provided :statuscode 403: the provided origin url is blacklisted :statuscode 404: no save requests have been found for a given origin - """ # noqa + """ if request.method == 'POST': sor = create_save_origin_request(origin_type, origin_url) diff --git a/swh/web/api/views/person.py b/swh/web/api/views/person.py --- a/swh/web/api/views/person.py +++ b/swh/web/api/views/person.py @@ -21,14 +21,17 @@ :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on :http:header:`Accept` header + of request :>json string email: the email of the person - :>json string fullname: the full name of the person: combination of its name and email + :>json string fullname: the full name of the person: combination of its + name and email :>json number id: the unique identifier of the person :>json string name: the name of the person - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 404: requested person can not be found in the archive @@ -38,7 +41,7 @@ .. parsed-literal:: :swh_web_api:`person/8275/` - """ # noqa + """ return api_lookup( service.lookup_person, person_id, notfound_msg='Person with id {} not found.'.format(person_id)) diff --git a/swh/web/api/views/release.py b/swh/web/api/views/release.py --- a/swh/web/api/views/release.py +++ b/swh/web/api/views/release.py @@ -17,30 +17,35 @@ """ .. http:get:: /api/1/release/(sha1_git)/ - Get information about a release in the archive. - Releases are identified by **sha1** checksums, compatible with Git tag identifiers. - See :func:`swh.model.identifiers.release_identifier` in our data model module for details - about how they are computed. + Get information about a release in the archive. Releases are identified + by **sha1** checksums, compatible with Git tag identifiers. See + :func:`swh.model.identifiers.release_identifier` in our data model + module for details about how they are computed. - :param string sha1_git: hexadecimal representation of the release **sha1_git** identifier + :param string sha1_git: hexadecimal representation of the release + **sha1_git** identifier :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on :http:header:`Accept` + header of request :>json object author: information about the author of the release - :>json string author_url: link to :http:get:`/api/1/person/(person_id)/` to get - information about the author of the release + :>json string author_url: link to + :http:get:`/api/1/person/(person_id)/` to get information about the + author of the release :>json string date: ISO representation of the release date (in UTC) :>json string id: the release unique identifier :>json string message: the message associated to the release :>json string name: the name of the release :>json string target: the target identifier of the release - :>json string target_type: the type of the target, can be either **release**, - **revision**, **content**, **directory** - :>json string target_url: a link to the adequate api url based on the target type + :>json string target_type: the type of the target, can be either + **release**, **revision**, **content**, **directory** + :>json string target_url: a link to the adequate api url based on the + target type - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 400: an invalid **sha1_git** value has been provided @@ -51,7 +56,7 @@ .. parsed-literal:: :swh_web_api:`release/208f61cc7a5dbc9879ae6e5c2f95891e270f09ef/` - """ # noqa + """ error_msg = 'Release with sha1_git %s not found.' % sha1_git return api_lookup( service.lookup_release, sha1_git, diff --git a/swh/web/api/views/revision.py b/swh/web/api/views/revision.py --- a/swh/web/api/views/revision.py +++ b/swh/web/api/views/revision.py @@ -278,38 +278,49 @@ """ .. http:get:: /api/1/revision/(sha1_git)/ - Get information about a revision in the archive. - Revisions are identified by **sha1** checksums, compatible with Git commit identifiers. - See :func:`swh.model.identifiers.revision_identifier` in our data model module for details - about how they are computed. + Get information about a revision in the archive. Revisions are + identified by **sha1** checksums, compatible with Git commit + identifiers. + See :func:`swh.model.identifiers.revision_identifier` in our data model + module for details about how they are computed. - :param string sha1_git: hexadecimal representation of the revision **sha1_git** identifier + :param string sha1_git: hexadecimal representation of the revision + **sha1_git** identifier :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on :http:header:`Accept` header + of request :>json object author: information about the author of the revision - :>json string author_url: link to :http:get:`/api/1/person/(person_id)/` to get - information about the author of the revision - :>json object committer: information about the committer of the revision - :>json string committer_url: link to :http:get:`/api/1/person/(person_id)/` to get - information about the committer of the revision - :>json string committer_date: ISO representation of the commit date (in UTC) + :>json string author_url: link to + :http:get:`/api/1/person/(person_id)/` to get information about the + author of the revision + :>json object committer: information about the committer of the + revision + :>json string committer_url: link to + :http:get:`/api/1/person/(person_id)/` to get information about the + committer of the revision + :>json string committer_date: ISO representation of the commit date + (in UTC) :>json string date: ISO representation of the revision date (in UTC) :>json string directory: the unique identifier that revision points to - :>json string directory_url: link to :http:get:`/api/1/directory/(sha1_git)/[(path)/]` - to get information about the directory associated to the revision + :>json string directory_url: link to + :http:get:`/api/1/directory/(sha1_git)/[(path)/]` to get + information about the directory associated to the revision :>json string id: the revision unique identifier - :>json boolean merge: whether or not the revision corresponds to a merge commit + :>json boolean merge: whether or not the revision corresponds to a + merge commit :>json string message: the message associated to the revision - :>json array parents: the parents of the revision, i.e. the previous revisions - that head directly to it, each entry of that array contains an unique parent - revision identifier but also a link to :http:get:`/api/1/revision/(sha1_git)/` - to get more information about it + :>json array parents: the parents of the revision, i.e. the previous + revisions that head directly to it, each entry of that array + contains an unique parent revision identifier but also a link to + :http:get:`/api/1/revision/(sha1_git)/` to get more information + about it :>json string type: the type of the revision - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 400: an invalid **sha1_git** value has been provided diff --git a/swh/web/api/views/snapshot.py b/swh/web/api/views/snapshot.py --- a/swh/web/api/views/snapshot.py +++ b/swh/web/api/views/snapshot.py @@ -21,17 +21,18 @@ Get information about a snapshot in the archive. - A snapshot is a set of named branches, which are pointers to objects at any - level of the Software Heritage DAG. It represents a full picture of an - origin at a given time. + A snapshot is a set of named branches, which are pointers to objects + at any level of the Software Heritage DAG. It represents a full picture + of an origin at a given time. - As well as pointing to other objects in the Software Heritage DAG, branches - can also be aliases, in which case their target is the name of another - branch in the same snapshot, or dangling, in which case the target is - unknown. + As well as pointing to other objects in the Software Heritage DAG, + branches can also be aliases, in which case their target is the name of + another branch in the same snapshot, or dangling, in which case the + target is unknown. - A snapshot identifier is a salted sha1. See :func:`swh.model.identifiers.snapshot_identifier` - in our data model module for details about how they are computed. + A snapshot identifier is a salted sha1. See + :func:`swh.model.identifiers.snapshot_identifier` in our data model + module for details about how they are computed. :param sha1 snapshot_id: a snapshot identifier :query str branches_from: optional parameter used to skip branches @@ -39,22 +40,25 @@ :query int branches_count: optional parameter used to restrain the amount of returned branches (default to 1000) :query str target_types: optional comma separated list parameter - used to filter the target types of branch to return (possible values - that can be contained in that list are ``content``, ``directory``, - ``revision``, ``release``, ``snapshot`` or ``alias``) + used to filter the target types of branch to return (possible + values that can be contained in that list are ``content``, + ``directory``, ``revision``, ``release``, ``snapshot`` or + ``alias``) :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request - :resheader Link: indicates that a subsequent result page is available and contains - the url pointing to it - - :>json object branches: object containing all branches associated to the snapshot, - for each of them the associated target type and id are given but also - a link to get information about that target + :resheader Content-Type: this depends on :http:header:`Accept` header + of request + :resheader Link: indicates that a subsequent result page is available + and contains the url pointing to it + + :>json object branches: object containing all branches associated to + the snapshot,for each of them the associated target type and id are + given but also a link to get information about that target :>json string id: the unique identifier of the snapshot - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 400: an invalid snapshot identifier has been provided @@ -65,7 +69,7 @@ .. parsed-literal:: :swh_web_api:`snapshot/6a3a2cf0b2b90ce7ae1cf0a221ed68035b686f5a/` - """ # noqa + """ def _enrich_snapshot(snapshot): s = snapshot.copy() diff --git a/swh/web/api/views/stat.py b/swh/web/api/views/stat.py --- a/swh/web/api/views/stat.py +++ b/swh/web/api/views/stat.py @@ -16,25 +16,33 @@ Get statistics about the content of the archive. - :>json number content: current number of content objects (aka files) in the archive - :>json number directory: current number of directory objects in the archive - :>json number origin: current number of software origins (an origin is a "place" where code - source can be found, e.g. a git repository, a tarball, ...) in the archive - :>json number origin_visit: current number of visits on software origins to fill the archive - :>json number person: current number of persons (code source authors or committers) + :>json number content: current number of content objects (aka files) in the archive - :>json number release: current number of releases objects in the archive - :>json number revision: current number of revision objects (aka commits) in the archive - :>json number skipped_content: current number of content objects (aka files) which where - not inserted in the archive - :>json number snapshot: current number of snapshot objects (aka set of named branches) + :>json number directory: current number of directory objects in the archive + :>json number origin: current number of software origins + (an origin is a "place" where code source can be found, e.g. a git + repository, a tarball, ...) in the archive + :>json number origin_visit: current number of visits on software + origins to fill the archive + :>json number person: current number of persons (code source authors + or committers) in the archive + :>json number release: current number of releases objects in the + archive + :>json number revision: current number of revision objects + (aka commits) in the archive + :>json number skipped_content: current number of content objects + (aka files) which where not inserted in the archive + :>json number snapshot: current number of snapshot objects + (aka set of named branches) in the archive :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on + :http:header:`Accept` header of request - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error @@ -43,5 +51,5 @@ .. parsed-literal:: :swh_web_api:`stat/counters/` - """ # noqa + """ return service.stat_counters() diff --git a/swh/web/api/views/vault.py b/swh/web/api/views/vault.py --- a/swh/web/api/views/vault.py +++ b/swh/web/api/views/vault.py @@ -50,7 +50,8 @@ through a GET request. Once the cooking task has been executed, the resulting archive can - be downloaded using the dedicated endpoint :http:get:`/api/1/vault/directory/(dir_id)/raw/`. + be downloaded using the dedicated endpoint + :http:get:`/api/1/vault/directory/(dir_id)/raw/`. Then to extract the cooked directory in the current one, use:: @@ -62,23 +63,28 @@ :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on + :http:header:`Accept` header of request - :>json string fetch_url: the url from which to download the archive once it has been cooked + :>json string fetch_url: the url from which to download the archive + once it has been cooked (see :http:get:`/api/1/vault/directory/(dir_id)/raw/`) - :>json string obj_type: the type of object to cook (directory or revision) - :>json string progress_message: message describing the cooking task progress + :>json string obj_type: the type of object to cook + (directory or revision) + :>json string progress_message: message describing the cooking task + progress :>json number id: the cooking task id - :>json string status: the cooking task status (either **new**, **pending**, - **done** or **failed**) + :>json string status: the cooking task status + (either **new**, **pending**, **done** or **failed**) :>json string obj_id: the identifier of the object to cook - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, + :http:method:`head`, :http:method:`options` :statuscode 200: no error :statuscode 400: an invalid directory identifier has been provided :statuscode 404: requested directory can not be found in the archive - """ # noqa + """ _, obj_id = query.parse_hash_with_algorithms_or_throws( dir_id, ['sha1'], 'Only sha1_git is supported.') @@ -105,12 +111,13 @@ :resheader Content-Type: application/octet-stream - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 400: an invalid directory identifier has been provided :statuscode 404: requested directory can not be found in the archive - """ # noqa + """ _, obj_id = query.parse_hash_with_algorithms_or_throws( dir_id, ['sha1'], 'Only sha1_git is supported.') res = api_lookup( @@ -140,8 +147,9 @@ through a POST request or check the status of a previously created one through a GET request. - Once the cooking task has been executed, the resulting gitfast archive can - be downloaded using the dedicated endpoint :http:get:`/api/1/vault/revision/(rev_id)/gitfast/raw/`. + Once the cooking task has been executed, the resulting gitfast archive + can be downloaded using the dedicated endpoint + :http:get:`/api/1/vault/revision/(rev_id)/gitfast/raw/`. Then to import the revision in the current directory, use:: @@ -155,22 +163,27 @@ :reqheader Accept: the requested response content type, either ``application/json`` (default) or ``application/yaml`` - :resheader Content-Type: this depends on :http:header:`Accept` header of request + :resheader Content-Type: this depends on + :http:header:`Accept` header of request - :>json string fetch_url: the url from which to download the archive once it has been cooked + :>json string fetch_url: the url from which to download the archive + once it has been cooked (see :http:get:`/api/1/vault/revision/(rev_id)/gitfast/raw/`) - :>json string obj_type: the type of object to cook (directory or revision) - :>json string progress_message: message describing the cooking task progress + :>json string obj_type: the type of object to cook + (directory or revision) + :>json string progress_message: message describing the cooking task + progress :>json number id: the cooking task id :>json string status: the cooking task status (new/pending/done/failed) :>json string obj_id: the identifier of the object to cook - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`post`, + :http:method:`head`, :http:method:`options` :statuscode 200: no error :statuscode 400: an invalid revision identifier has been provided :statuscode 404: requested revision can not be found in the archive - """ # noqa + """ _, obj_id = query.parse_hash_with_algorithms_or_throws( rev_id, ['sha1'], 'Only sha1_git is supported.') @@ -197,12 +210,13 @@ :resheader Content-Type: application/octet-stream - **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, :http:method:`options` + **Allowed HTTP Methods:** :http:method:`get`, :http:method:`head`, + :http:method:`options` :statuscode 200: no error :statuscode 400: an invalid revision identifier has been provided :statuscode 404: requested revision can not be found in the archive - """ # noqa + """ _, obj_id = query.parse_hash_with_algorithms_or_throws( rev_id, ['sha1'], 'Only sha1_git is supported.') res = api_lookup( diff --git a/swh/web/browse/utils.py b/swh/web/browse/utils.py --- a/swh/web/browse/utils.py +++ b/swh/web/browse/utils.py @@ -286,13 +286,14 @@ Args: snapshot_branches (dict): A dict describing the branches of a snapshot - as returned for instance by :func:`swh.web.common.service.lookup_snapshot` + as returned for instance by + :func:`swh.web.common.service.lookup_snapshot` Returns: tuple: A tuple whose first member is the sorted list of branches targeting revisions and second member the sorted list of branches targeting releases - """ # noqa + """ snapshot_branches = snapshot['branches'] branches = {} branch_aliases = {} @@ -880,7 +881,8 @@ snapshot_id (str): hexadecimal representation of a snapshot identifier, all other parameters will be ignored if it is provided origin_type (str): the origin type (git, svn, deposit, ...) - origin_url (str): the origin_url (e.g. https://github.com/(user)/(repo)/) + origin_url (str): the origin_url + (e.g. https://github.com/(user)/(repo)/) timestamp (str): a datetime string for retrieving the closest visit of the origin visit_id (int): optional visit id for disambiguation in case @@ -904,7 +906,7 @@ Raises: NotFoundExc: if no snapshot is found for the visit of an origin. - """ # noqa + """ origin_info = None visit_info = None url_args = None @@ -1081,20 +1083,22 @@ Args: swh_objects (list): a list of dict with the following keys: - * type: swh object type (content/directory/release/revision/snapshot) + * type: swh object type + (content/directory/release/revision/snapshot) * id: swh object id - snapshot_context (dict): optional parameter describing the snapshot in which - the object has been found + snapshot_context (dict): optional parameter describing the snapshot in + which the object has been found Returns: list: a list of dict with the following keys: - * object_type: the swh object type (content/directory/release/revision/snapshot) + * object_type: the swh object type + (content/directory/release/revision/snapshot) * object_icon: the swh object icon to use in HTML views * swh_id: the computed swh object persistent identifier * swh_id_url: the url resolving the persistent identifier - * show_options: boolean indicating if the persistent id options must - be displayed in persistent ids HTML view - """ # noqa + * show_options: boolean indicating if the persistent id options + must be displayed in persistent ids HTML view + """ swh_ids = [] for swh_object in swh_objects: if not swh_object['id']: diff --git a/swh/web/browse/views/content.py b/swh/web/browse/views/content.py --- a/swh/web/browse/views/content.py +++ b/swh/web/browse/views/content.py @@ -34,8 +34,9 @@ """Django view that produces a raw display of a content identified by its hash value. - The url that points to it is :http:get:`/browse/content/[(algo_hash):](hash)/raw/` - """ # noqa + The url that points to it is + :http:get:`/browse/content/[(algo_hash):](hash)/raw/` + """ try: reencode = bool(strtobool(request.GET.get('reencode', 'false'))) algo, checksum = query.parse_hash(query_string) @@ -170,8 +171,9 @@ """Django view that produces an HTML display of a content identified by its hash value. - The url that points to it is :http:get:`/browse/content/[(algo_hash):](hash)/` - """ # noqa + The url that points to it is + :http:get:`/browse/content/[(algo_hash):](hash)/` + """ try: algo, checksum = query.parse_hash(query_string) checksum = hash_to_hex(checksum) diff --git a/swh/web/browse/views/directory.py b/swh/web/browse/views/directory.py --- a/swh/web/browse/views/directory.py +++ b/swh/web/browse/views/directory.py @@ -31,8 +31,9 @@ """Django view for browsing the content of a directory identified by its sha1_git value. - The url that points to it is :http:get:`/browse/directory/(sha1_git)/[(path)/]` - """ # noqa + The url that points to it is + :http:get:`/browse/directory/(sha1_git)/[(path)/]` + """ root_sha1_git = sha1_git try: if path: diff --git a/swh/web/browse/views/origin.py b/swh/web/browse/views/origin.py --- a/swh/web/browse/views/origin.py +++ b/swh/web/browse/views/origin.py @@ -30,14 +30,20 @@ browse_snapshot_releases ) -@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)/visit/(?P.+)/directory/', # noqa - r'origin/(?P[a-z]+)/url/(?P.+)/visit/(?P.+)/directory/(?P.+)/', # noqa - r'origin/(?P[a-z]+)/url/(?P.+)/directory/', # noqa - r'origin/(?P[a-z]+)/url/(?P.+)/directory/(?P.+)/', # noqa - r'origin/(?P.+)/visit/(?P.+)/directory/', # noqa - r'origin/(?P.+)/visit/(?P.+)/directory/(?P.+)/', # noqa - r'origin/(?P.+)/directory/', # noqa - r'origin/(?P.+)/directory/(?P.+)/', # noqa + +@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)' + '/visit/(?P.+)/directory/', + r'origin/(?P[a-z]+)/url/(?P.+)' + '/visit/(?P.+)/directory/(?P.+)/', + r'origin/(?P[a-z]+)/url/(?P.+)' + '/directory/', + r'origin/(?P[a-z]+)/url/(?P.+)' + '/directory/(?P.+)/', + r'origin/(?P.+)/visit/(?P.+)/directory/', + r'origin/(?P.+)/visit/(?P.+)' + '/directory/(?P.+)/', + r'origin/(?P.+)/directory/', + r'origin/(?P.+)/directory/(?P.+)/', view_name='browse-origin-directory') def origin_directory_browse(request, origin_url, origin_type=None, timestamp=None, path=None): @@ -54,10 +60,13 @@ timestamp=timestamp, path=path) -@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)/visit/(?P.+)/content/(?P.+)/', # noqa - r'origin/(?P[a-z]+)/url/(?P.+)/content/(?P.+)/', # noqa - r'origin/(?P.+)/visit/(?P.+)/content/(?P.+)/', # noqa - r'origin/(?P.+)/content/(?P.+)/', # noqa +@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)' + '/visit/(?P.+)/content/(?P.+)/', + r'origin/(?P[a-z]+)/url/(?P.+)' + '/content/(?P.+)/', + r'origin/(?P.+)/visit/(?P.+)' + '/content/(?P.+)/', + r'origin/(?P.+)/content/(?P.+)/', view_name='browse-origin-content') def origin_content_browse(request, origin_url, origin_type=None, path=None, timestamp=None): @@ -78,9 +87,10 @@ PER_PAGE = 20 -@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)/visit/(?P.+)/log/', # noqa +@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)' + '/visit/(?P.+)/log/', r'origin/(?P[a-z]+)/url/(?P.+)/log/', - r'origin/(?P.+)/visit/(?P.+)/log/', # noqa + r'origin/(?P.+)/visit/(?P.+)/log/', r'origin/(?P.+)/log/', view_name='browse-origin-log') def origin_log_browse(request, origin_url, origin_type=None, timestamp=None): @@ -95,10 +105,13 @@ return browse_snapshot_log(request, origin_type=origin_type, origin_url=origin_url, timestamp=timestamp) -@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)/visit/(?P.+)/branches/', # noqa - r'origin/(?P[a-z]+)/url/(?P.+)/branches/', # noqa - r'origin/(?P.+)/visit/(?P.+)/branches/', # noqa - r'origin/(?P.+)/branches/', # noqa + +@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)' + '/visit/(?P.+)/branches/', + r'origin/(?P[a-z]+)/url/(?P.+)' + '/branches/', + r'origin/(?P.+)/visit/(?P.+)/branches/', + r'origin/(?P.+)/branches/', view_name='browse-origin-branches') def origin_branches_browse(request, origin_url, origin_type=None, timestamp=None): @@ -115,10 +128,12 @@ origin_url=origin_url, timestamp=timestamp) -@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)/visit/(?P.+)/releases/', # noqa - r'origin/(?P[a-z]+)/url/(?P.+)/releases/', # noqa - r'origin/(?P.+)/visit/(?P.+)/releases/', # noqa - r'origin/(?P.+)/releases/', # noqa +@browse_route(r'origin/(?P[a-z]+)/url/(?P.+)' + '/visit/(?P.+)/releases/', + r'origin/(?P[a-z]+)/url/(?P.+)' + '/releases/', + r'origin/(?P.+)/visit/(?P.+)/releases/', + r'origin/(?P.+)/releases/', view_name='browse-origin-releases') def origin_releases_browse(request, origin_url, origin_type=None, timestamp=None): @@ -142,8 +157,9 @@ """Django view that produces an HTML display of visits reporting for a swh origin identified by its id or its url. - The url that points to it is :http:get:`/browse/origin/[(origin_type)/url/](origin_url)/visits/`. - """ # noqa + The url that points to it is + :http:get:`/browse/origin/[(origin_type)/url/](origin_url)/visits/`. + """ try: origin_info = get_origin_info(origin_url, origin_type) origin_visits = get_origin_visits(origin_info) @@ -285,7 +301,7 @@ def origin_browse(request, origin_url, origin_type=None): """Django view that redirects to the display of the latest archived snapshot for a given software origin. - """ # noqa + """ last_snapshot_url = reverse('browse-origin-directory', url_args={'origin_type': origin_type, 'origin_url': origin_url}) diff --git a/swh/web/browse/views/revision.py b/swh/web/browse/views/revision.py --- a/swh/web/browse/views/revision.py +++ b/swh/web/browse/views/revision.py @@ -183,7 +183,7 @@ log for a revision identified by its id. The url that points to it is :http:get:`/browse/revision/(sha1_git)/log/` - """ # noqa + """ try: per_page = int(request.GET.get('per_page', NB_LOG_ENTRIES)) offset = int(request.GET.get('offset', 0)) diff --git a/swh/web/browse/views/snapshot.py b/swh/web/browse/views/snapshot.py --- a/swh/web/browse/views/snapshot.py +++ b/swh/web/browse/views/snapshot.py @@ -38,8 +38,9 @@ """Django view for browsing the content of a directory collected in a snapshot. - The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/directory/[(path)/]` - """ # noqa + The url that points to it is + :http:get:`/browse/snapshot/(snapshot_id)/directory/[(path)/]` + """ origin_type = request.GET.get('origin_type', None) origin_url = request.GET.get('origin_url', None) if not origin_url: @@ -56,8 +57,9 @@ """Django view that produces an HTML display of a content collected in a snapshot. - The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/content/(path)/` - """ # noqa + The url that points to it is + :http:get:`/browse/snapshot/(snapshot_id)/content/(path)/` + """ return browse_snapshot_content(request, snapshot_id=snapshot_id, path=path) @@ -68,8 +70,9 @@ """Django view that produces an HTML display of revisions history (aka the commit log) collected in a snapshot. - The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/log/` - """ # noqa + The url that points to it is + :http:get:`/browse/snapshot/(snapshot_id)/log/` + """ return browse_snapshot_log(request, snapshot_id=snapshot_id) @@ -80,8 +83,9 @@ """Django view that produces an HTML display of the list of releases collected in a snapshot. - The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/branches/` - """ # noqa + The url that points to it is + :http:get:`/browse/snapshot/(snapshot_id)/branches/` + """ return browse_snapshot_branches(request, snapshot_id=snapshot_id) @@ -92,6 +96,7 @@ """Django view that produces an HTML display of the list of releases collected in a snapshot. - The url that points to it is :http:get:`/browse/snapshot/(snapshot_id)/releases/` - """ # noqa + The url that points to it is + :http:get:`/browse/snapshot/(snapshot_id)/releases/` + """ return browse_snapshot_releases(request, snapshot_id=snapshot_id) diff --git a/swh/web/common/utils.py b/swh/web/common/utils.py --- a/swh/web/common/utils.py +++ b/swh/web/common/utils.py @@ -225,12 +225,13 @@ Returns: dict: a dict with the following keys: - * **swh_id_parsed (swh.model.identifiers.PersistentId)**: the parsed identifier + * **swh_id_parsed (swh.model.identifiers.PersistentId)**: + the parsed identifier * **browse_url (str)**: the url for browsing the pointed object Raises: BadInputExc: if the provided identifier can not be parsed - """ # noqa + """ try: swh_id_parsed = parse_persistent_identifier(swh_id) object_type = swh_id_parsed.object_type