Skip to content

AttributeError: 'str' object has no attribute 'write' #5

@bionade24

Description

@bionade24

Python Version: 3.8.2
Code:

    def delete_package_line(self, file):
        sed = Sed()
        try:
            sed.no_autoprint = True
            sed.regexp_extended = False
            sed.load_string("/{0}/d".format(self.package))
            sed.apply(file, output=file)
            print("applied")
        except SedException as e:
            print(e.message)
            raise

When I change sed.no_autoprint to False, I get no error but I doesn't work either. Calling pythonsed -e /name/d success.txt worked fine.

Traceback (most recent call last):
  File "./ci.py", line 7, in <module>
    parser.main(argv[1:])
  File "/home/oskar/workspace/aur-ci/aurci/parser.py", line 30, in main
    commands(args.command, args.package, args.verbose, args.quiet)
  File "/home/oskar/workspace/aur-ci/aurci/parser.py", line 17, in commands
    getattr(command_class[0](package, verbosity, output), command_class[1])()
  File "/home/oskar/workspace/aur-ci/aurci/bootstrap.py", line 42, in pull
    self.delete_package_line("success.txt")
  File "/home/oskar/workspace/aur-ci/aurci/general.py", line 18, in delete_package_line
    sed.apply(file, "test.txt")
  File "/usr/lib/python3.8/site-packages/PythonSed/sed.py", line 179, in apply
    self.printline(self.PS)
  File "/usr/lib/python3.8/site-packages/PythonSed/sed.py", line 139, in printline
    print(line, file=self.output)
AttributeError: 'str' object has no attribute 'write'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions