当前位置: 首页>>代码示例>>Python>>正文


Python FileAsObj.log方法代码示例

本文整理汇总了Python中fileasobj.FileAsObj.log方法的典型用法代码示例。如果您正苦于以下问题:Python FileAsObj.log方法的具体用法?Python FileAsObj.log怎么用?Python FileAsObj.log使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在fileasobj.FileAsObj的用法示例。


在下文中一共展示了FileAsObj.log方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_logging_enabled

# 需要导入模块: from fileasobj import FileAsObj [as 别名]
# 或者: from fileasobj.FileAsObj import log [as 别名]
 def test_logging_enabled(self):
     """ Test local log enabled by default. """
     test_file = FileAsObj()
     self.assertIsNotNone(str(test_file.log))
     test_file.log('FINDME')
     self.assertTrue('FINDME' in str(test_file.log))
     self.assertTrue('FINDME' in test_file.log.trace)
开发者ID:jhazelwo,项目名称:python-fileasobj,代码行数:9,代码来源:tests_fileasobj.py

示例2: print

# 需要导入模块: from fileasobj import FileAsObj [as 别名]
# 或者: from fileasobj.FileAsObj import log [as 别名]
my_file.rm(my_file.grep('foo'))


#
# Check for line in file, if exists remove it
if 'foo bar' in my_file:
    my_file.rm('foo bar')
# or
my_file.rm(my_file.check('foo bar'))
# or
my_file.rm('foo bar')  # OK if line not found.


#
# Now that you've changed data let's save it back to disk.
my_file.save()
# or
my_file.write()
# of
if my_file.virgin is False:
    my_file.save()


#
# NOTE: you'll probably never need to worry about this part. If it doesn't make sense, just ignore it.
# As things are checked or changed with FileAsObj an internal log is updated.
# To view it:
print(my_file.log)
# If you want to manually add something:
my_file.log('A manual log entry')  # This does not change the file, just the log attribute of the object.
开发者ID:jkudria,项目名称:fileasobj,代码行数:32,代码来源:examples.py

示例3: test_string_log_call

# 需要导入模块: from fileasobj import FileAsObj [as 别名]
# 或者: from fileasobj.FileAsObj import log [as 别名]
 def test_string_log_call(self):
     """ Test __call__ method of log subclass. """
     test_file = FileAsObj()
     self.assertIsNone(test_file.log('test'))
开发者ID:jhazelwo,项目名称:python-fileasobj,代码行数:6,代码来源:tests_fileasobj.py

示例4: test_logging_disable

# 需要导入模块: from fileasobj import FileAsObj [as 别名]
# 或者: from fileasobj.FileAsObj import log [as 别名]
 def test_logging_disable(self):
     """ Test disabled local log. """
     test_file = FileAsObj(logging=False)
     test_file.log('logging disabled this will not be saved')
     self.assertTrue(str(test_file.log) == '')
     self.assertTrue(test_file.log.trace == '')
开发者ID:jhazelwo,项目名称:python-fileasobj,代码行数:8,代码来源:tests_fileasobj.py

示例5: example_manually_update_change_log

# 需要导入模块: from fileasobj import FileAsObj [as 别名]
# 或者: from fileasobj.FileAsObj import log [as 别名]
def example_manually_update_change_log():
    """  You can inject an arbitrary message to the log sub-class by calling it. """
    my_file = FileAsObj('/tmp/example_file.txt')
    my_file.log('A manual log entry.')
开发者ID:jhazelwo,项目名称:python-fileasobj,代码行数:6,代码来源:examples.py


注:本文中的fileasobj.FileAsObj.log方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。