1
+ <!--
2
+ -- Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved.
3
+ -- SPDX-License-Identifier: Apache-2.0
4
+ -->
5
+ <!doctype html>
6
+ < html lang ="en ">
7
+ < head >
8
+ < meta charset ="utf-8 ">
9
+ < meta name ="viewport " content ="width=device-width, initial-scale=1, minimum-scale=1 " />
10
+ < meta name ="generator " content ="pdoc 0.9.1 " />
11
+ < title > continuous_delivery_scripts.get_version API documentation</ title >
12
+ < meta name ="description " content ="Determine the project new version. " />
13
+ < link rel ="preload stylesheet " as ="style " href ="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/sanitize.min.css " integrity ="sha256-PK9q560IAAa6WVRRh76LtCaI8pjTJ2z11v0miyNNjrs= " crossorigin >
14
+ < link rel ="preload stylesheet " as ="style " href ="https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/11.0.1/typography.min.css " integrity ="sha256-7l/o7C8jubJiy74VsKTidCy1yBkRtiUGbVkYBylBqUg= " crossorigin >
15
+ < link rel ="stylesheet preload " as ="style " href ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/styles/github.min.css " crossorigin >
16
+ < style > : root {--highlight-color : # fe9 }.flex {display : flex !important }body {line-height : 1.5em }# content {padding : 20px }# sidebar {padding : 30px ;overflow : hidden}# sidebar > * : last-child {margin-bottom : 2cm }.http-server-breadcrumbs {font-size : 130% ;margin : 0 0 15px 0 }# footer {font-size : .75em ;padding : 5px 30px ;border-top : 1px solid # ddd ;text-align : right}# footer p {margin : 0 0 0 1em ;display : inline-block}# footer p : last-child {margin-right : 30px }h1 , h2 , h3 , h4 , h5 {font-weight : 300 }h1 {font-size : 2.5em ;line-height : 1.1em }h2 {font-size : 1.75em ;margin : 1em 0 .50em 0 }h3 {font-size : 1.4em ;margin : 25px 0 10px 0 }h4 {margin : 0 ;font-size : 105% }h1 : target , h2 : target , h3 : target , h4 : target , h5 : target , h6 : target {background : var (--highlight-color );padding : .2em 0 }a {color : # 058 ;text-decoration : none;transition : color .3s ease-in-out}a : hover {color : # e82 }.title code {font-weight : bold}h2 [id ^= "header-" ]{margin-top : 2em }.ident {color : # 900 }pre code {background : # f8f8f8 ;font-size : .8em ;line-height : 1.4em }code {background : # f2f2f1 ;padding : 1px 4px ;overflow-wrap : break-word}h1 code {background : transparent}pre {background : # f8f8f8 ;border : 0 ;border-top : 1px solid # ccc ;border-bottom : 1px solid # ccc ;margin : 1em 0 ;padding : 1ex }# http-server-module-list {display : flex;flex-flow : column}# http-server-module-list div {display : flex}# http-server-module-list dt {min-width : 10% }# http-server-module-list p {margin-top : 0 }.toc ul , # index {list-style-type : none;margin : 0 ;padding : 0 }# index code {background : transparent}# index h3 {border-bottom : 1px solid # ddd }# index ul {padding : 0 }# index h4 {margin-top : .6em ;font-weight : bold}@media (min-width : 200ex ){# index .two-column {column-count : 2 }}@media (min-width : 300ex ){# index .two-column {column-count : 3 }}dl {margin-bottom : 2em }dl dl : last-child {margin-bottom : 4em }dd {margin : 0 0 1em 3em }# header-classes + dl > dd {margin-bottom : 3em }dd dd {margin-left : 2em }dd p {margin : 10px 0 }.name {background : # eee ;font-weight : bold;font-size : .85em ;padding : 5px 10px ;display : inline-block;min-width : 40% }.name : hover {background : # e0e0e0 }dt : target .name {background : var (--highlight-color )}.name > span : first-child {white-space : nowrap}.name .class > span : nth-child (2 ){margin-left : .4em }.inherited {color : # 999 ;border-left : 5px solid # eee ;padding-left : 1em }.inheritance em {font-style : normal;font-weight : bold}.desc h2 {font-weight : 400 ;font-size : 1.25em }.desc h3 {font-size : 1em }.desc dt code {background : inherit}.source summary , .git-link-div {color : # 666 ;text-align : right;font-weight : 400 ;font-size : .8em ;text-transform : uppercase}.source summary > * {white-space : nowrap;cursor : pointer}.git-link {color : inherit;margin-left : 1em }.source pre {max-height : 500px ;overflow : auto;margin : 0 }.source pre code {font-size : 12px ;overflow : visible}.hlist {list-style : none}.hlist li {display : inline}.hlist li : after {content : ',\2002' }.hlist li : last-child : after {content : none}.hlist .hlist {display : inline;padding-left : 1em }img {max-width : 100% }td {padding : 0 .5em }.admonition {padding : .1em .5em ;margin-bottom : 1em }.admonition-title {font-weight : bold}.admonition .note , .admonition .info , .admonition .important {background : # aef }.admonition .todo , .admonition .versionadded , .admonition .tip , .admonition .hint {background : # dfd }.admonition .warning , .admonition .versionchanged , .admonition .deprecated {background : # fd4 }.admonition .error , .admonition .danger , .admonition .caution {background : lightpink}</ style >
17
+ < style media ="screen and (min-width: 700px) "> @media screen and (min-width : 700px ){# sidebar {width : 30% ;height : 100vh ;overflow : auto;position : sticky;top : 0 }# content {width : 70% ;max-width : 100ch ;padding : 3em 4em ;border-left : 1px solid # ddd }pre code {font-size : 1em }.item .name {font-size : 1em }main {display : flex;flex-direction : row-reverse;justify-content : flex-end}.toc ul ul , # index ul {padding-left : 1.5em }.toc > ul > li {margin-top : .5em }}</ style >
18
+ < style media ="print "> @media print{# sidebar h1 {page-break-before : always}.source {display : none}}@media print{* {background : transparent !important ;color : # 000 !important ;box-shadow : none !important ;text-shadow : none !important }a [href ]: after {content : " (" attr (href) ")" ;font-size : 90% }a [href ][title ]: after {content : none}abbr [title ]: after {content : " (" attr (title) ")" }.ir a : after , a [href ^= "javascript:" ]: after , a [href ^= "#" ]: after {content : "" }pre , blockquote {border : 1px solid # 999 ;page-break-inside : avoid}thead {display : table-header-group}tr , img {page-break-inside : avoid}img {max-width : 100% !important }@page {margin : 0.5cm }p , h2 , h3 {orphans : 3 ;widows : 3 }h1 , h2 , h3 , h4 , h5 , h6 {page-break-after : avoid}}</ style >
19
+ < script defer src ="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/10.1.1/highlight.min.js " integrity ="sha256-Uv3H6lx7dJmRfRvH8TH6kJD1TSK1aFcwgx+mdg3epi8= " crossorigin > </ script >
20
+ < script > window . addEventListener ( 'DOMContentLoaded' , ( ) => hljs . initHighlighting ( ) ) </ script >
21
+ </ head >
22
+ < body >
23
+ < main >
24
+ < article id ="content ">
25
+ < header >
26
+ < h1 class ="title "> Module < code > continuous_delivery_scripts.get_version</ code > </ h1 >
27
+ </ header >
28
+ < section id ="section-intro ">
29
+ < p > Determine the project new version.</ p >
30
+ < details class ="source ">
31
+ < summary >
32
+ < span > Expand source code</ span >
33
+ </ summary >
34
+ < pre > < code class ="python "> #
35
+ # Copyright (C) 2020-2021 Arm Limited or its affiliates and Contributors. All rights reserved.
36
+ # SPDX-License-Identifier: Apache-2.0
37
+ #
38
+ """Determine the project new version."""
39
+ import sys
40
+
41
+ import argparse
42
+ import logging
43
+ from continuous_delivery_scripts.utils.versioning import calculate_version, determine_version_string
44
+
45
+ from continuous_delivery_scripts.utils.definitions import CommitType
46
+ from continuous_delivery_scripts.utils.logging import log_exception, set_log_level
47
+
48
+ logger = logging.getLogger(__name__)
49
+
50
+
51
+ def get_project_version_string(commit_type: CommitType) -> str:
52
+ """Determine the project version string.
53
+
54
+ Args:
55
+ commit_type: states what is the type of the commit
56
+
57
+
58
+ Returns:
59
+ (is new version, the new version)
60
+ """
61
+ use_news_files = commit_type in [CommitType.BETA, CommitType.RELEASE]
62
+ _, new_version, version_elements = calculate_version(commit_type, use_news_files)
63
+ version_string = determine_version_string(commit_type, new_version, version_elements)
64
+ return version_string
65
+
66
+
67
+ def main() -> None:
68
+ """Handle command line arguments to determine version string."""
69
+ parser = argparse.ArgumentParser(description="Determine project's version.")
70
+ parser.add_argument(
71
+ "-t", "--release-type", help="type of release to perform", required=True, type=str, choices=CommitType.choices()
72
+ )
73
+ parser.add_argument("-v", "--verbose", action="count", default=0, help="Verbosity, by default errors are reported.")
74
+ args = parser.parse_args()
75
+ set_log_level(args.verbose)
76
+
77
+ try:
78
+ commit_type = CommitType.parse(args.release_type)
79
+ version_to_print = get_project_version_string(commit_type)
80
+ print(version_to_print)
81
+ except Exception as e:
82
+ log_exception(logger, e)
83
+ sys.exit(1)
84
+
85
+
86
+ if __name__ == "__main__":
87
+ main()</ code > </ pre >
88
+ </ details >
89
+ </ section >
90
+ < section >
91
+ </ section >
92
+ < section >
93
+ </ section >
94
+ < section >
95
+ < h2 class ="section-title " id ="header-functions "> Functions</ h2 >
96
+ < dl >
97
+ < dt id ="continuous_delivery_scripts.get_version.get_project_version_string "> < code class ="name flex ">
98
+ < span > def < span class ="ident "> get_project_version_string</ span > </ span > (< span > commit_type: < a title ="continuous_delivery_scripts.utils.definitions.CommitType " href ="utils/definitions.html#continuous_delivery_scripts.utils.definitions.CommitType "> CommitType</ a > ) ‑> str</ span >
99
+ </ code > </ dt >
100
+ < dd >
101
+ < div class ="desc "> < p > Determine the project version string.</ p >
102
+ < h2 id ="args "> Args</ h2 >
103
+ < dl >
104
+ < dt > < strong > < code > commit_type</ code > </ strong > </ dt >
105
+ < dd > states what is the type of the commit</ dd >
106
+ </ dl >
107
+ < h2 id ="returns "> Returns</ h2 >
108
+ < p > (is new version, the new version)</ p > </ div >
109
+ < details class ="source ">
110
+ < summary >
111
+ < span > Expand source code</ span >
112
+ </ summary >
113
+ < pre > < code class ="python "> def get_project_version_string(commit_type: CommitType) -> str:
114
+ """Determine the project version string.
115
+
116
+ Args:
117
+ commit_type: states what is the type of the commit
118
+
119
+
120
+ Returns:
121
+ (is new version, the new version)
122
+ """
123
+ use_news_files = commit_type in [CommitType.BETA, CommitType.RELEASE]
124
+ _, new_version, version_elements = calculate_version(commit_type, use_news_files)
125
+ version_string = determine_version_string(commit_type, new_version, version_elements)
126
+ return version_string</ code > </ pre >
127
+ </ details >
128
+ </ dd >
129
+ < dt id ="continuous_delivery_scripts.get_version.main "> < code class ="name flex ">
130
+ < span > def < span class ="ident "> main</ span > </ span > (< span > ) ‑> NoneType</ span >
131
+ </ code > </ dt >
132
+ < dd >
133
+ < div class ="desc "> < p > Handle command line arguments to determine version string.</ p > </ div >
134
+ < details class ="source ">
135
+ < summary >
136
+ < span > Expand source code</ span >
137
+ </ summary >
138
+ < pre > < code class ="python "> def main() -> None:
139
+ """Handle command line arguments to determine version string."""
140
+ parser = argparse.ArgumentParser(description="Determine project's version.")
141
+ parser.add_argument(
142
+ "-t", "--release-type", help="type of release to perform", required=True, type=str, choices=CommitType.choices()
143
+ )
144
+ parser.add_argument("-v", "--verbose", action="count", default=0, help="Verbosity, by default errors are reported.")
145
+ args = parser.parse_args()
146
+ set_log_level(args.verbose)
147
+
148
+ try:
149
+ commit_type = CommitType.parse(args.release_type)
150
+ version_to_print = get_project_version_string(commit_type)
151
+ print(version_to_print)
152
+ except Exception as e:
153
+ log_exception(logger, e)
154
+ sys.exit(1)</ code > </ pre >
155
+ </ details >
156
+ </ dd >
157
+ </ dl >
158
+ </ section >
159
+ < section >
160
+ </ section >
161
+ </ article >
162
+ < nav id ="sidebar ">
163
+ < h1 > Index</ h1 >
164
+ < div class ="toc ">
165
+ < ul > </ ul >
166
+ </ div >
167
+ < ul id ="index ">
168
+ < li > < h3 > Super-module</ h3 >
169
+ < ul >
170
+ < li > < code > < a title ="continuous_delivery_scripts " href ="index.html "> continuous_delivery_scripts</ a > </ code > </ li >
171
+ </ ul >
172
+ </ li >
173
+ < li > < h3 > < a href ="#header-functions "> Functions</ a > </ h3 >
174
+ < ul class ="">
175
+ < li > < code > < a title ="continuous_delivery_scripts.get_version.get_project_version_string " href ="#continuous_delivery_scripts.get_version.get_project_version_string "> get_project_version_string</ a > </ code > </ li >
176
+ < li > < code > < a title ="continuous_delivery_scripts.get_version.main " href ="#continuous_delivery_scripts.get_version.main "> main</ a > </ code > </ li >
177
+ </ ul >
178
+ </ li >
179
+ </ ul >
180
+ </ nav >
181
+ </ main >
182
+ < footer id ="footer ">
183
+ < p > Generated by < a href ="https://pdoc3.github.io/pdoc "> < cite > pdoc</ cite > 0.9.1</ a > .</ p >
184
+ </ footer >
185
+ </ body >
186
+ </ html >
0 commit comments