import os

from lib.base import DockerBasePythonAction


__all__ = [
    'DockerBuildImageAction'
]


class DockerBuildImageAction(DockerBasePythonAction):
    def run(self, dockerfile_path, tag):
        if os.path.isdir(dockerfile_path):
            return self.wrapper.build(path=dockerfile_path, tag=tag)
        else:
            with open(dockerfile_path, 'r') as fp:
                return self.wrapper.build(fileobj=fp, tag=tag)

import os

from lib.base import DockerBasePythonAction


__all__ = [
    'DockerBuildImageAction'
]


class DockerBuildImageAction(DockerBasePythonAction):
    def run(self, dockerfile_path, tag):
        if os.path.isdir(dockerfile_path):
            return self.wrapper.build(path=dockerfile_path, tag=tag)
        else:
            dockerfile_path = os.path.expanduser(dockerfile_path)
            with open(dockerfile_path, 'r') as fp:
                return self.wrapper.build(fileobj=fp, tag=tag)

Expand user in the path.
Expand user in the path.

  import os
  
  from lib.base import DockerBasePythonAction
  
  
  __all__ = [
      'DockerBuildImageAction'
  ]
  
  
  class DockerBuildImageAction(DockerBasePythonAction):
      def run(self, dockerfile_path, tag):
          if os.path.isdir(dockerfile_path):
              return self.wrapper.build(path=dockerfile_path, tag=tag)
          else:
+             dockerfile_path = os.path.expanduser(dockerfile_path)
              with open(dockerfile_path, 'r') as fp:
                  return self.wrapper.build(fileobj=fp, tag=tag)
  
Expand user in the path.
## Code Before:
import os

from lib.base import DockerBasePythonAction


__all__ = [
    'DockerBuildImageAction'
]


class DockerBuildImageAction(DockerBasePythonAction):
    def run(self, dockerfile_path, tag):
        if os.path.isdir(dockerfile_path):
            return self.wrapper.build(path=dockerfile_path, tag=tag)
        else:
            with open(dockerfile_path, 'r') as fp:
                return self.wrapper.build(fileobj=fp, tag=tag)

## Instruction:
Expand user in the path.
## Code After:
import os

from lib.base import DockerBasePythonAction


__all__ = [
    'DockerBuildImageAction'
]


class DockerBuildImageAction(DockerBasePythonAction):
    def run(self, dockerfile_path, tag):
        if os.path.isdir(dockerfile_path):
            return self.wrapper.build(path=dockerfile_path, tag=tag)
        else:
            dockerfile_path = os.path.expanduser(dockerfile_path)
            with open(dockerfile_path, 'r') as fp:
                return self.wrapper.build(fileobj=fp, tag=tag)
