plexpy/lib/win32comext/shell/demos/ITransferAdviseSink.py
dependabot[bot] faef9a94c4
Bump cherrypy from 18.8.0 to 18.9.0 (#2266)
* Bump cherrypy from 18.8.0 to 18.9.0

Bumps [cherrypy](https://github.com/cherrypy/cherrypy) from 18.8.0 to 18.9.0.
- [Changelog](https://github.com/cherrypy/cherrypy/blob/main/CHANGES.rst)
- [Commits](https://github.com/cherrypy/cherrypy/compare/v18.8.0...v18.9.0)

---
updated-dependencies:
- dependency-name: cherrypy
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

* Update cherrypy==18.9.0

---------

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com>

[skip ci]
2024-03-24 15:25:44 -07:00

107 lines
2.8 KiB
Python

# ITransferAdviseSink implementation template
import pythoncom
from win32com.server.policy import DesignatedWrapPolicy
from win32com.shell import shell, shellcon
tsf_flags = list(
(k, v) for k, v in list(shellcon.__dict__.items()) if k.startswith("TSF_")
)
def decode_flags(flags):
if flags == 0:
return "TSF_NORMAL"
flag_txt = ""
for k, v in tsf_flags:
if flags & v:
if flag_txt:
flag_txt = flag_txt + "|" + k
else:
flag_txt = k
return flag_txt
TRANSFER_ADVISE_STATES = {}
for k, v in list(shellcon.__dict__.items()):
if k.startswith("TS_"):
TRANSFER_ADVISE_STATES[v] = k
def decode_flags(flags):
if flags == 0:
return "TSF_NORMAL"
flag_txt = ""
for k, v in tsf_flags:
if flags & v:
if flag_txt:
flag_txt = flag_txt + "|" + k
else:
flag_txt = k
return flag_txt
class TransferAdviseSink(DesignatedWrapPolicy):
_com_interfaces_ = [shell.IID_ITransferAdviseSink]
_public_methods_ = [
"UpdateProgress",
"UpdateTransferState",
"ConfirmOverwrite",
"ConfirmEncryptionLoss",
"FileFailure",
"SubStreamFailure",
"PropertyFailure",
]
def __init__(self):
self._wrap_(self)
def UpdateProgress(
self,
SizeCurrent,
SizeTotal,
FilesCurrent,
FilesTotal,
FoldersCurrent,
FoldersTotal,
):
print("UpdateProgress - processed so far:")
print("\t %s out of %s bytes" % (SizeCurrent, SizeTotal))
print("\t %s out of %s files" % (FilesCurrent, FilesTotal))
print("\t %s out of %s folders" % (FoldersCurrent, FoldersTotal))
def UpdateTransferState(self, State):
print(
"Current state: ",
TRANSFER_ADVISE_STATES.get(State, "??? Unknown state %s ???" % State),
)
def ConfirmOverwrite(self, Source, DestParent, Name):
print(
"ConfirmOverwrite: ",
Source.GetDisplayName(shellcon.SHGDN_FORPARSING),
DestParent.GetDisplayName(shellcon.SHGDN_FORPARSING),
Name,
)
def ConfirmEncryptionLoss(self, Source):
print(
"ConfirmEncryptionLoss:", Source.GetDisplayName(shellcon.SHGDN_FORPARSING)
)
def FileFailure(self, Item, ItemName, Error):
print("FileFailure:", Item.GetDisplayName(shellcon.SHGDN_FORPARSING), ItemName)
def SubStreamFailure(self, Item, StreamName, Error):
print("SubStreamFailure:\n")
def PropertyFailure(self, Item, key, Error):
print("PropertyFailure:\n")
def CreateSink():
return pythoncom.WrapObject(
TransferAdviseSink(),
shell.IID_ITransferAdviseSink,
shell.IID_ITransferAdviseSink,
)