class_docstr: Contains Kubernetes Airflow Worker configuration logic.
  
  Represents a kubernetes pod and manages execution of a single pod.
  Any configuration that is container specific gets applied to
  the first container in the list of containers.
  
  :param pod: The fully specified pod. Mutually exclusive with `pod_template_file`
  :param pod_template_file: Path to YAML file. Mutually exclusive with `pod`
  :param extract_xcom: Whether to bring up a container for xcom
docstr: Convert to pod from obj.
docstr_tok: ["Convert","to","pod","from","obj","."]
code: def from_legacy_obj(obj) -> k8s.V1Pod | None:
      """Convert to pod from obj."""
      if obj is None:
          return None
  
      # We do not want to extract constant here from ExecutorLoader because it is just
      # A name in dictionary rather than executor selection mechanism and it causes cyclic import
      namespaced = obj.get("KubernetesExecutor", {})
  
      if not namespaced:
          return None
  
      resources = namespaced.get("resources")
  
      if resources is None:
          requests = {
              "cpu": namespaced.pop("request_cpu", None),
              "memory": namespaced.pop("request_memory", None),
              "ephemeral-storage": namespaced.get(
                  "ephemeral-storage"
              ),  # We pop this one in limits
          }
          limits = {
              "cpu": namespaced.pop("limit_cpu", None),
              "memory": namespaced.pop("limit_memory", None),
              "ephemeral-storage": namespaced.pop(
                  "ephemeral-storage", None
              ),
          }
          all_resources = list(requests.values()) + list(
              limits.values()
          )
          if all(r is None for r in all_resources):
              resources = None
          else:
              # remove None's so they don't become 0's
              requests = {
                  k: v for k, v in requests.items() if v is not None
              }
              limits = {
                  k: v for k, v in limits.items() if v is not None
              }
              resources = k8s.V1ResourceRequirements(
                  requests=requests, limits=limits
              )
      namespaced["resources"] = resources
      return PodGeneratorDeprecated(**namespaced).gen_pod()
  
imports: from __future__ import annotations
  import copy
  import logging
  import os
  import secrets
  import string
  import warnings
  from functools import reduce
  from typing import TYPE_CHECKING
  import re2
  from dateutil import parser
  from kubernetes.client import models
  from kubernetes.client.api_client import ApiClient
  from airflow.exceptions import AirflowConfigException, PodMutationHookException, PodReconciliationError, RemovedInAirflow3Warning
  from airflow.kubernetes.pre_7_4_0_compatibility.pod_generator_deprecated import PodDefaults, PodGenerator
  from airflow.utils import yaml
  from airflow.utils.hashlib_wrapper import md5
  from airflow.version import version
label_desc: Use image node_id 5 for calling the PodGenerator obj's underlying member method code with example usage: obj.from_legacy_obj(obj) and returns: PodGeneratorDeprecated, None, None