rendercv.data.models.computers
¶
The rendercv.data.models.computers
module contains functions that compute some
properties based on the input data. For example, it includes functions that calculate
the time span between two dates, the date string, the URL of a social network, etc.
format_phone_number(phone_number)
¶
Format a phone number to the format specified in the locale_catalog
dictionary.
Parameters:
-
phone_number
(str
) –The phone number to format.
Returns:
-
str
–The formatted phone number.
Source code in rendercv/data/models/computers.py
format_date(date, date_style=None)
¶
Formats a Date
object to a string in the following format: "Jan 2021". The
month names are taken from the locale_catalog
dictionary from the
rendercv.data_models.models
module.
Parameters:
-
date
(date
) –The date to format.
-
date_style
(Optional[str]
, default:None
) –The style of the date string. If not provided, the default date style from the
locale_catalog
dictionary will be used.
Returns:
-
str
–The formatted date.
Source code in rendercv/data/models/computers.py
replace_placeholders(value)
¶
Replaces the placeholders in a string with the corresponding values.
Source code in rendercv/data/models/computers.py
convert_string_to_path(value)
¶
Converts a string to a pathlib.Path
object by replacing the placeholders
with the corresponding values. If the path is not an absolute path, it is
converted to an absolute path by prepending the current working directory.
Source code in rendercv/data/models/computers.py
compute_time_span_string(start_date, end_date, date)
¶
Return a time span string based on the provided dates.
Parameters:
-
start_date
(Optional[str | int]
) –A start date in YYYY-MM-DD, YYYY-MM, or YYYY format.
-
end_date
(Optional[str | int]
) –An end date in YYYY-MM-DD, YYYY-MM, or YYYY format or "present".
-
date
(Optional[str | int]
) –A date in YYYY-MM-DD, YYYY-MM, or YYYY format or a custom string. If provided, start_date and end_date will be ignored.
Returns:
-
str
–The computed time span string.
Source code in rendercv/data/models/computers.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 |
|
compute_date_string(start_date, end_date, date, show_only_years=False)
¶
Return a date string based on the provided dates.
Parameters:
-
start_date
(Optional[str | int]
) –A start date in YYYY-MM-DD, YYYY-MM, or YYYY format.
-
end_date
(Optional[str | int]
) –An end date in YYYY-MM-DD, YYYY-MM, or YYYY format or "present".
-
date
(Optional[str | int]
) –A date in YYYY-MM-DD, YYYY-MM, or YYYY format or a custom string. If provided, start_date and end_date will be ignored.
-
show_only_years
(bool
, default:False
) –If True, only the years will be shown in the date string.
Returns:
-
str
–The computed date string.
Source code in rendercv/data/models/computers.py
232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
|
make_a_url_clean(url)
¶
Make a URL clean by removing the protocol, www, and trailing slashes.
Parameters:
-
url
(str
) –The URL to make clean.
Returns:
-
str
–The clean URL.
Source code in rendercv/data/models/computers.py
get_date_object(date)
¶
Parse a date string in YYYY-MM-DD, YYYY-MM, or YYYY format and return a
datetime.date
object. This function is used throughout the validation process of
the data models.
Parameters:
-
date
(str | int
) –The date string to parse.
Returns:
-
date
–The parsed date.
Source code in rendercv/data/models/computers.py
dictionary_key_to_proper_section_title(key)
¶
Convert a dictionary key to a proper section title.
Parameters:
-
key
(str
) –The key to convert to a proper section title.
Returns:
-
str
–The proper section title.