def parse_string( self, string, source_string=None, locale=None, path=None, source_path=None, ): """Android XML files must contain the word 'strings'.""" path = create_named_tempfile( string, prefix='strings', suffix='.xml', directory=self.tempdir, ) if source_string is not None: source_path = create_named_tempfile( source_string, prefix='strings', suffix='.xml', directory=self.tempdir, ) return super(AndroidXMLTests, self).parse_string( string, source_string=source_string, locale=locale, path=path, source_path=source_path, )
def parse_string( self, string, source_string=None, locale=None, path=None, source_path=None, ): """Android XML files must contain the word 'strings'.""" path = create_named_tempfile( string, prefix="strings", suffix=".xml", directory=self.tempdir, ) if source_string is not None: source_path = create_named_tempfile( source_string, prefix="strings", suffix=".xml", directory=self.tempdir, ) return super().parse_string( string, source_string=source_string, locale=locale, path=path, source_path=source_path, )
def test_parse_with_no_source_path(self): contents = "text = Arise, awake and do not stop until the goal is reached." path = create_named_tempfile( contents, prefix="strings", suffix=".ftl", directory=self.tempdir, ) obj = ftl.parse(path, source_path=None, locale=None) assert obj.path == path assert obj.source_resource is None assert obj.locale is None
def get_nonexistant_file_resource(self, path): contents = "text = Arise, awake and do not stop until the goal is reached." source_path = create_named_tempfile( contents, prefix="strings", suffix=".ftl", directory=self.tempdir, ) source_resource = ftl.FTLResource( path=source_path, locale=None, source_resource=None ) return ftl.FTLResource(path, locale=None, source_resource=source_resource,)
def test_parse_with_source_path(self): contents = "text = Arise, awake and do not stop until the goal is reached." source_path = create_named_tempfile( contents, prefix="strings", suffix=".ftl", directory=self.tempdir, ) path = self.get_nonexistant_file_path() obj = ftl.parse(path, source_path=source_path, locale=None) assert_equal(obj.path, path) assert_equal(obj.locale, None) assert_equal(obj.source_resource.path, source_path) assert_equal(obj.source_resource.locale, None)
def test_parse_with_no_source_path(self): contents = "text = Arise, awake and do not stop until the goal is reached." path = create_named_tempfile( contents, prefix='strings', suffix='.ftl', directory=self.tempdir, ) obj = ftl.parse(path, source_path=None, locale=None) assert_equal(obj.path, path) assert_equal(obj.source_resource, None) assert_equal(obj.locale, None)
def get_nonexistant_file_resource(self, path): contents = "text = Arise, awake and do not stop until the goal is reached." source_path = create_named_tempfile( contents, prefix='strings', suffix='.ftl', directory=self.tempdir, ) source_resource = ftl.FTLResource(path=source_path, locale=None, source_resource=None) return ftl.FTLResource( path, locale=None, source_resource=source_resource, )
def get_nonexistant_file_resource(self, path): contents = dedent( """<?xml version="1.0" encoding="utf-8"?> <resources> <string name="source-string">Source String</string> </resources> """ ) source_path = create_named_tempfile( contents, prefix="strings", suffix=".xml", directory=self.tempdir, ) source_resource = compare_locales.CompareLocalesResource(source_path) return compare_locales.CompareLocalesResource( path, source_resource=source_resource, )
def get_nonexistant_file_resource(self, path): contents = dedent("""<?xml version="1.0" encoding="utf-8"?> <resources> <string name="source-string">Source String</string> </resources> """) source_path = create_named_tempfile( contents, prefix='strings', suffix='.xml', directory=self.tempdir, ) source_resource = compare_locales.CompareLocalesResource(source_path) return compare_locales.CompareLocalesResource( path, source_resource=source_resource, )