|
11 | 11 | import dateutil.parser
|
12 | 12 | import ssl
|
13 | 13 |
|
14 |
| -from .common import ClientError, LoginError |
| 14 | +from .common import ClientError, LoginError, InvalidProject |
15 | 15 | from .merginproject import MerginProject
|
16 |
| -from .client_pull import download_project_async, download_project_wait, download_project_finalize |
| 16 | +from .client_pull import ( |
| 17 | + download_file_finalize, |
| 18 | + download_project_async, |
| 19 | + download_file_async, |
| 20 | + download_diffs_async, |
| 21 | + download_project_finalize, |
| 22 | + download_project_wait, |
| 23 | + download_diffs_finalize, |
| 24 | +) |
17 | 25 | from .client_pull import pull_project_async, pull_project_wait, pull_project_finalize
|
18 | 26 | from .client_push import push_project_async, push_project_wait, push_project_finalize
|
19 |
| -from .utils import DateTimeEncoder |
| 27 | +from .utils import DateTimeEncoder, get_versions_with_file_changes |
20 | 28 | from .version import __version__
|
21 | 29 |
|
22 | 30 | this_dir = os.path.dirname(os.path.realpath(__file__))
|
@@ -618,3 +626,38 @@ def get_projects_by_names(self, projects):
|
618 | 626 |
|
619 | 627 | resp = self.post("/v1/project/by_names", {"projects": projects}, {"Content-Type": "application/json"})
|
620 | 628 | return json.load(resp)
|
| 629 | + |
| 630 | + def download_file(self, project_dir, file_path, output_filename, version=None): |
| 631 | + """ |
| 632 | + Download project file at specified version. Get the latest if no version specified. |
| 633 | +
|
| 634 | + :param project_dir: project local directory |
| 635 | + :type project_dir: String |
| 636 | + :param file_path: relative path of file to download in the project directory |
| 637 | + :type file_path: String |
| 638 | + :param output_filename: full destination path for saving the downloaded file |
| 639 | + :type output_filename: String |
| 640 | + :param version: optional version tag for downloaded file |
| 641 | + :type version: String |
| 642 | + """ |
| 643 | + job = download_file_async(self, project_dir, file_path, output_filename, version=version) |
| 644 | + pull_project_wait(job) |
| 645 | + download_file_finalize(job) |
| 646 | + |
| 647 | + def get_file_diff(self, project_dir, file_path, output_diff, version_from, version_to): |
| 648 | + """ Create concatenated diff for project file diffs between versions version_from and version_to. |
| 649 | +
|
| 650 | + :param project_dir: project local directory |
| 651 | + :type project_dir: String |
| 652 | + :param file_path: relative path of file to download in the project directory |
| 653 | + :type file_path: String |
| 654 | + :param output_diff: full destination path for concatenated diff file |
| 655 | + :type output_diff: String |
| 656 | + :param version_from: starting project version tag for getting diff, for example 'v3' |
| 657 | + :type version_from: String |
| 658 | + :param version_to: ending project version tag for getting diff |
| 659 | + :type version_to: String |
| 660 | + """ |
| 661 | + job = download_diffs_async(self, project_dir, file_path, version_from, version_to) |
| 662 | + pull_project_wait(job) |
| 663 | + download_diffs_finalize(job, output_diff) |
0 commit comments