shorten po/check_po lines (indent=4-chars, etc.)
This commit is contained in:
parent
9f843464b3
commit
9335a21e3a
73
po/check_po
73
po/check_po
@ -241,7 +241,8 @@ class Msgid:
|
||||
|
||||
def diag( self ):
|
||||
print
|
||||
print("msg nr: %d, lineno: %d%s" % ( self.nr, self.lineno, self.is_fuzzy and " (fuzzy)" or "" ))
|
||||
print("msg nr: %d, lineno: %d%s" %
|
||||
( self.nr, self.lineno, self.is_fuzzy and " (fuzzy)" or "" ))
|
||||
sys.stdout.write( ''.join( self._msgid ) )
|
||||
sys.stdout.write( ''.join( self._msgidp ) )
|
||||
sys.stdout.write( ''.join( self._msgstr ) )
|
||||
@ -344,21 +345,25 @@ def read_msgs( fname ):
|
||||
# expect msgid or comment or old stuff
|
||||
if next_state == CMNT:
|
||||
state = CMNT
|
||||
msg = create_new_Msgid( msgs, lineno ) # Start with an empty new item
|
||||
# Start with an empty new item
|
||||
msg = create_new_Msgid( msgs, lineno )
|
||||
msg.add_cmnt( line )
|
||||
|
||||
elif next_state == MSGID:
|
||||
state = MSGID
|
||||
msg = create_new_Msgid( msgs, lineno ) # Start with an empty new item
|
||||
# Start with an empty new item
|
||||
msg = create_new_Msgid( msgs, lineno )
|
||||
msg.add_msgid( line, lineno )
|
||||
|
||||
elif next_state == MSGIDP:
|
||||
raise CheckException( 'Unexpected %(next_state)s at %(fname)s:%(lineno)d' % vars() )
|
||||
raise CheckException( 'Unexpected %(next_state)s '
|
||||
'at %(fname)s:%(lineno)d' % vars() )
|
||||
|
||||
elif next_state == MSGSTR:
|
||||
print('WARNING: Wild msgstr at %(fname)s:%(lineno)d' % vars())
|
||||
state = MSGSTR
|
||||
msg = create_new_Msgid( msgs, lineno ) # Start with an empty new item
|
||||
# Start with an empty new item
|
||||
msg = create_new_Msgid( msgs, lineno )
|
||||
msg.add_new_msgstr( line, lineno )
|
||||
|
||||
elif next_state == STR:
|
||||
@ -368,10 +373,12 @@ def read_msgs( fname ):
|
||||
pass # Just skip
|
||||
|
||||
else:
|
||||
raise CheckException( 'Unexpected state in po parsing (state = %(state)s)' % vars() )
|
||||
raise CheckException( 'Unexpected state in po parsing '
|
||||
'(state = %(state)s)' % vars() )
|
||||
|
||||
elif state == CMNT:
|
||||
# Expect more comment, or msgid. If msgstr or string it is flagged as error.
|
||||
# Expect more comment, or msgid.
|
||||
# If msgstr or string it is flagged as error.
|
||||
if next_state == CMNT:
|
||||
if msg:
|
||||
msg.add_cmnt( line )
|
||||
@ -383,16 +390,19 @@ def read_msgs( fname ):
|
||||
elif next_state == MSGID:
|
||||
state = MSGID
|
||||
if not msg:
|
||||
msg = create_new_Msgid( msgs, lineno ) # Start with an empty new item
|
||||
# Start with an empty new item
|
||||
msg = create_new_Msgid( msgs, lineno )
|
||||
msg.add_msgid( line, lineno )
|
||||
|
||||
elif next_state == MSGIDP:
|
||||
raise CheckException( 'Unexpected %(next_state)s at %(fname)s:%(lineno)d' % vars() )
|
||||
raise CheckException( 'Unexpected %(next_state)s '
|
||||
'at %(fname)s:%(lineno)d' % vars() )
|
||||
|
||||
elif next_state == MSGSTR:
|
||||
print('WARNING: Wild msgstr at %(fname)s:%(lineno)d' % vars())
|
||||
state = MSGSTR
|
||||
msg = create_new_Msgid( msgs, lineno ) # Start with an empty new item
|
||||
# Start with an empty new item
|
||||
msg = create_new_Msgid( msgs, lineno )
|
||||
msg.add_new_msgstr( line, lineno )
|
||||
|
||||
elif next_state == STR:
|
||||
@ -403,16 +413,19 @@ def read_msgs( fname ):
|
||||
pass # Just skip
|
||||
|
||||
else:
|
||||
raise CheckException( 'Unexpected state in po parsing (state = %(state)s)' % vars() )
|
||||
raise CheckException( 'Unexpected state in po parsing '
|
||||
'(state = %(state)s)' % vars() )
|
||||
|
||||
elif state == MSGID:
|
||||
# Expect msgstr or msgid_plural or string
|
||||
if next_state == CMNT:
|
||||
# Hmmm. A comment here?
|
||||
print('WARNING: Unexpted comment at %(fname)s:%(lineno)d' % vars())
|
||||
print('WARNING: Unexpted comment '
|
||||
'at %(fname)s:%(lineno)d' % vars())
|
||||
|
||||
elif next_state == MSGID:
|
||||
raise CheckException( 'Unexpected %(next_state)s at %(fname)s:%(lineno)d' % vars() )
|
||||
raise CheckException( 'Unexpected %(next_state)s '
|
||||
'at %(fname)s:%(lineno)d' % vars() )
|
||||
|
||||
elif next_state == MSGIDP:
|
||||
state = MSGIDP
|
||||
@ -431,19 +444,23 @@ def read_msgs( fname ):
|
||||
pass # Just skip
|
||||
|
||||
else:
|
||||
raise CheckException( 'Unexpected state in po parsing (state = %(state)s)' % vars() )
|
||||
raise CheckException( 'Unexpected state in po parsing '
|
||||
'(state = %(state)s)' % vars() )
|
||||
|
||||
elif state == MSGIDP:
|
||||
# Expect msgstr or string or comment
|
||||
if next_state == CMNT:
|
||||
# Hmmm. A comment here?
|
||||
print('WARNING: Unexpted comment at %(fname)s:%(lineno)d' % vars())
|
||||
print('WARNING: Unexpected comment '
|
||||
'at %(fname)s:%(lineno)d' % vars())
|
||||
|
||||
elif next_state == MSGID:
|
||||
raise CheckException( 'Unexpected %(next_state)s at %(fname)s:%(lineno)d' % vars() )
|
||||
raise CheckException( 'Unexpected %(next_state)s '
|
||||
'at %(fname)s:%(lineno)d' % vars() )
|
||||
|
||||
elif next_state == MSGIDP:
|
||||
raise CheckException( 'Unexpected %(next_state)s at %(fname)s:%(lineno)d' % vars() )
|
||||
raise CheckException( 'Unexpected %(next_state)s '
|
||||
'at %(fname)s:%(lineno)d' % vars() )
|
||||
|
||||
elif next_state == MSGSTR:
|
||||
state = MSGSTR
|
||||
@ -458,7 +475,8 @@ def read_msgs( fname ):
|
||||
pass # Just skip
|
||||
|
||||
else:
|
||||
raise CheckException( 'Unexpected state in po parsing (state = %(state)s)' % vars() )
|
||||
raise CheckException( 'Unexpected state in po parsing '
|
||||
'(state = %(state)s)' % vars() )
|
||||
|
||||
elif state == MSGSTR:
|
||||
# Expect comment, or msgid, or string.
|
||||
@ -474,7 +492,8 @@ def read_msgs( fname ):
|
||||
msg.add_msgid( line, lineno )
|
||||
|
||||
elif next_state == MSGIDP:
|
||||
raise CheckException( 'Unexpected %(next_state)s at %(fname)s:%(lineno)d' % vars() )
|
||||
raise CheckException( 'Unexpected %(next_state)s '
|
||||
'at %(fname)s:%(lineno)d' % vars() )
|
||||
|
||||
elif next_state == MSGSTR:
|
||||
# New msgstr, probably for plural form
|
||||
@ -489,10 +508,12 @@ def read_msgs( fname ):
|
||||
pass # Just skip
|
||||
|
||||
else:
|
||||
raise CheckException( 'Unexpected state in po parsing (state = %(state)s)' % vars() )
|
||||
raise CheckException( 'Unexpected state in po parsing '
|
||||
'(state = %(state)s)' % vars() )
|
||||
|
||||
else:
|
||||
raise CheckException( 'Unexpected state in po parsing (state = %(state)s)' % vars() )
|
||||
raise CheckException( 'Unexpected state in po parsing '
|
||||
'(state = %(state)s)' % vars() )
|
||||
|
||||
# Strip items with just comments. (Can this happen?)
|
||||
msgs1 = []
|
||||
@ -570,11 +591,15 @@ def analyze_msgs( args, fname, msgs, nr_templates = None, nth = 0 ):
|
||||
|
||||
def main():
|
||||
|
||||
parser = ArgumentParser( description='This program validates a PO file for GRAMPS.')
|
||||
parser = ArgumentParser(description='This program validates '
|
||||
'a PO file for GRAMPS.')
|
||||
|
||||
parser.add_argument("-s", dest="summary",
|
||||
choices=[file for file in os.listdir('.') if file.endswith('.po')],
|
||||
default=False, help="the summary of check, and if need, it gives details")
|
||||
choices=[file for file in os.listdir('.')
|
||||
if file.endswith('.po')],
|
||||
default=False,
|
||||
help="the summary of check, "
|
||||
"and if need, it gives details")
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user