-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathact.py
More file actions
67 lines (62 loc) · 1.96 KB
/
act.py
File metadata and controls
67 lines (62 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#
#Copyright (C) 2009 asylumfunk
#
#This program is free software: you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#
#You may obtain a copy of this license at:
# http://www.gnu.org/licenses/gpl-3.0.html
"""Business logic layer"""
#Standard modules
import os
#Project modules
import config
from default import cfg
"""
Description:
Appends the default footer to the status
If necessary, mesage is truncated to fit the footer
Args:
message::string : original status (without footer)
maxLength::int : maximum status length (including footer)
Returns:
string : new status (including footer), <= maxLength
"""
def appendFooterToStatus( message, maxLength, suffix ):
status = message + " " + suffix
if len( status ) > maxLength:
truncator = cfg.get( "status.truncation" )
status = message[ 0 : ( maxLength - len( suffix ) - len( truncator ) - 1 ) ] + truncator + " " + suffix
return status
"""
Description:
Parses the base filename (without extension) from a path name
Args:
file::string : the file's path
Returns:
string : the base filename (without extension) of the path
"""
def parseTitleFromFilename( file ):
return os.path.splitext( os.path.split( file )[ 1 ] )[ 0 ]
"""
Description:
Strips newline characters from the input string
Args:
text::string - input text
[replacementString::string = " "] - string used to replace newlines
Returns:
None if input is None
Else, text with all newline instances replaced by the replacement string
"""
def stripNewlines( text, replacementString = " " ):
if text is None:
return text
else:
return text.replace( "\n", replacementString )